cesardias on Nostr: Highly recommend rxjs, it's been an incredible journey for me and I had to learn some ...
Highly recommend rxjs, it's been an incredible journey for me and I had to learn some things the hard way.
After a heavy year on rxjs, I manage to build very complex pipelines with have very little state (variables) and close to no imperative code, I kinda got to a point of no way back.
Your approach of takeUntil is totally correct, which is the rxjs way of doing things, a powerful advice to rxjs is to avoid Subjects at all costs, they deviate the concepts of reactive programming and forces you in the imperative approach, people using rxjs with only Subjects aren't really using rxjs at all, just a fancy event emitter (the meme), there's a reason why xstream (a alternative library to rxjs) called their `next` function `shamefullySendNext` (yes, there's use cases for Subjects)
I have no issues with typescript in rxjs, it works pretty well and point-free operators would work just fine, I have issues naming things properly.
You have to be careful as well where you subscribe to the observables, it should be the final stage and usually close to the UI, and unsubscribe when the ui is "unmounted".
I was writing this document for
hzrd149 (nprofile…aql4) the other day but never had a change to finish, which is my client approach for nostr subscription in rxjs
https://github.com/cesardeazevedo/nostr-observable, the idea was to have a 100% stateless library for nostr.
This file is how I handle subscription and everything else is built on top of it
https://github.com/cesardeazevedo/nosotros/blob/main/src/core/operators/subscribe.tsIf you have any questions don't hesitate to ask, I would love to help anything rxjs related.
Published at
2025-03-26 18:28:21Event JSON
{
"id": "1e6e86da97442e85866b93eb7ade12e76c860943cf6641fc4e7b14e73f7d0662",
"pubkey": "c6603b0f1ccfec625d9c08b753e4f774eaf7d1cf2769223125b5fd4da728019e",
"created_at": 1743013701,
"kind": 1,
"tags": [
[
"e",
"7232af889e79b07bc8dab1307acc24766bd869f9a9be3ff86f8239be532ef2f9",
"wss://hbr.coracle.social",
"root",
"97c70a44366a6535c145b333f973ea86dfdc2d7a99da618c40c64705ad98e322"
],
[
"p",
"97c70a44366a6535c145b333f973ea86dfdc2d7a99da618c40c64705ad98e322",
"wss://nos.lol"
],
[
"p",
"266815e0c9210dfa324c6cba3573b14bee49da4209a9456f9484e5106cd408a5",
"wss://satellite.hzrd149.com"
],
[
"client",
"nosotros",
"31990:c6603b0f1ccfec625d9c08b753e4f774eaf7d1cf2769223125b5fd4da728019e:1728437063755"
]
],
"content": "Highly recommend rxjs, it's been an incredible journey for me and I had to learn some things the hard way.\n\nAfter a heavy year on rxjs, I manage to build very complex pipelines with have very little state (variables) and close to no imperative code, I kinda got to a point of no way back.\n\nYour approach of takeUntil is totally correct, which is the rxjs way of doing things, a powerful advice to rxjs is to avoid Subjects at all costs, they deviate the concepts of reactive programming and forces you in the imperative approach, people using rxjs with only Subjects aren't really using rxjs at all, just a fancy event emitter (the meme), there's a reason why xstream (a alternative library to rxjs) called their `next` function `shamefullySendNext` (yes, there's use cases for Subjects)\n\nI have no issues with typescript in rxjs, it works pretty well and point-free operators would work just fine, I have issues naming things properly.\n\nYou have to be careful as well where you subscribe to the observables, it should be the final stage and usually close to the UI, and unsubscribe when the ui is \"unmounted\".\n\nI was writing this document for nostr:nprofile1qydhwumn8ghj7umpw3jkcmrfw3jju6r6wfjrzdpe9e3k7mgpz9mhxue69uhkummnw3e82efwvdhk6qg5waehxw309aex2mrp0yhxgctdw4eju6t0qyxhwumn8ghj7mn0wvhxcmmvqyg8wumn8ghj7mn0wd68ytnhd9hx2qpqye5ptcxfyyxl5vjvdjar2ua3f0hynkjzpx552mu5snj3qmx5pzjs7haql4 the other day but never had a change to finish, which is my client approach for nostr subscription in rxjs https://github.com/cesardeazevedo/nostr-observable, the idea was to have a 100% stateless library for nostr.\n\nThis file is how I handle subscription and everything else is built on top of it https://github.com/cesardeazevedo/nosotros/blob/main/src/core/operators/subscribe.ts\n\nIf you have any questions don't hesitate to ask, I would love to help anything rxjs related.",
"sig": "85dc537a42a7c657938590e34a522b5dc6f7d431cee2e4b8fda4465c268226a95b87da9aa8c869510b288691bc10fa80097d5c6bed1889a05e4668d904b7cde1"
}