hzrd149 on Nostr: Just finished a the first working version of the applesauce-loaders package ...
Just finished a the first working version of the applesauce-loaders package
https://github.com/hzrd149/applesauce/tree/master/packages/loaders
The documentation is very sparse at the moment but the package exports a class called `ReplaceableLoader` that can be used to dynamically load any replaceable event (1xxxx, and 3xxxx) from any relay in a efficient manor.
In theory it also respects the relays limits because it uses rx-nostr under the hood to make the requests
Its all built on rxjs and the loader is simply a rxjs Subject that takes an AddressPointer as an input and outputs events it loads from relays
The cool part was figuring out how to make it load from the cache relays first, then the remote relays, and finally the fallback "lookup" relays
I ended up using a generator function, first time I've ever used one in javascript 😀
https://github.com/hzrd149/applesauce/blob/master/packages/loaders/src/loaders/replaceable-loader.ts#L32-L92
I'm really proud of this and how well it works, but I would appreciate any feedback from other nostr devs interested. I promise ill try to write better docs next week so the code is easier to read
You can see a working example of it over on https://blossomservers.com/reviews I doesn't look like much, its just loading profiles but it proves its working 😀
https://github.com/hzrd149/applesauce/tree/master/packages/loaders
The documentation is very sparse at the moment but the package exports a class called `ReplaceableLoader` that can be used to dynamically load any replaceable event (1xxxx, and 3xxxx) from any relay in a efficient manor.
In theory it also respects the relays limits because it uses rx-nostr under the hood to make the requests
Its all built on rxjs and the loader is simply a rxjs Subject that takes an AddressPointer as an input and outputs events it loads from relays
The cool part was figuring out how to make it load from the cache relays first, then the remote relays, and finally the fallback "lookup" relays
I ended up using a generator function, first time I've ever used one in javascript 😀
https://github.com/hzrd149/applesauce/blob/master/packages/loaders/src/loaders/replaceable-loader.ts#L32-L92
I'm really proud of this and how well it works, but I would appreciate any feedback from other nostr devs interested. I promise ill try to write better docs next week so the code is easier to read
You can see a working example of it over on https://blossomservers.com/reviews I doesn't look like much, its just loading profiles but it proves its working 😀