Re-work feed to reduce annoyance of calling loaders

This commit is contained in:
Jon Staab
2024-11-07 09:07:03 -08:00
parent a3987cbf88
commit 0074b51aba
6 changed files with 165 additions and 121 deletions
+11 -11
View File
@@ -5,14 +5,6 @@ A custom feed compiler and loader for nostr. Read the spec on [wikifreedia](http
# Example
```javascript
// Configure the feed loader so it can access your app's context and make requests
const loader = new FeedLoader({
request,
requestDvm,
getPubkeysForScope,
getPubkeysForWotRange,
})
// Define a feed using set operations
const feed = intersectionFeed(
unionFeed(
@@ -26,9 +18,17 @@ const feed = intersectionFeed(
scopeFeed("global"),
)
// Load notes using the feed
loader.compiler.getLoader(feed, {
// Create a controller
const controller = new FeedController({
feed,
request,
requestDvm,
getPubkeysForScope,
getPubkeysForWotRange,
onEvent: event => console.log("Event", event),
onExhausted: () => console.log("Exhausted"),
onExhausted: () => console.log("Exhausted"),
})
// Load notes using the feed
controller.load(10)
```