This commit is contained in:
Shusui MOYATANI
2023-03-17 09:38:28 +09:00
parent 158d0e3a20
commit c34143065b
23 changed files with 421 additions and 246 deletions

View File

@@ -8,6 +8,7 @@ export type UseSubscriptionProps = {
options?: SubscriptionOptions;
// subscribe not only stored events but also new events published after the subscription
// default is true
clientEventFilter?: (event: NostrEvent) => boolean;
continuous?: boolean;
onEvent?: (event: NostrEvent) => void;
onEOSE?: () => void;
@@ -36,6 +37,9 @@ const useSubscription = (propsProvider: () => UseSubscriptionProps | null) => {
if (onEvent != null) {
onEvent(event);
}
if (props.clientEventFilter != null && !props.clientEventFilter(event)) {
return;
}
if (!eose) {
pushed = true;
storedEvents.push(event);