applesauce-react 0.0.0-next-20250217154504 → 0.0.0-next-20250217174538

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,12 @@
1
1
  # applesauce-react
2
2
 
3
- React hooks for applesauce
3
+ React hooks and providers for applesauce
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install applesauce-react
9
+ ```
4
10
 
5
11
  ## Example
6
12
 
@@ -9,8 +15,8 @@ import { EventStore, QueryStore, Queries } from "applesauce-core";
9
15
  import { QueryStoreProvider } from "applesauce-react/providers";
10
16
  import { useStoreQuery } from "applesauce-react/hooks";
11
17
 
12
- const events = new EventStore();
13
- const store = new QueryStore(events);
18
+ const eventStore = new EventStore();
19
+ const queryStore = new QueryStore(eventStore);
14
20
 
15
21
  function UserName({ pubkey }) {
16
22
  const profile = useStoreQuery(Queries.ProfileQuery, [pubkey]);
@@ -20,7 +26,7 @@ function UserName({ pubkey }) {
20
26
 
21
27
  function App() {
22
28
  return (
23
- <QueryStoreProvider store={store}>
29
+ <QueryStoreProvider queryStore={queryStore}>
24
30
  <h1>App</h1>
25
31
 
26
32
  <UserName pubkey="82341f882b6eabcd2ba7f1ef90aad961cf074af15b9ef44a09f9d2a8fbfbe6a2" />
@@ -1,6 +1,6 @@
1
- import { useObservable } from "./use-observable.js";
1
+ import { useObservableEagerState } from "observable-hooks";
2
2
  import { useAccountManager } from "./use-account-manager.js";
3
3
  export function useAccounts() {
4
4
  const manager = useAccountManager();
5
- return useObservable(manager.accounts$);
5
+ return useObservableEagerState(manager.accounts$);
6
6
  }
@@ -1,6 +1,6 @@
1
- import { useObservable } from "./use-observable.js";
1
+ import { useObservableEagerState } from "observable-hooks";
2
2
  import { useAccountManager } from "./use-account-manager.js";
3
3
  export function useActiveAccount() {
4
4
  const manager = useAccountManager();
5
- return useObservable(manager.active$);
5
+ return useObservableEagerState(manager.active$);
6
6
  }
@@ -1,4 +1,4 @@
1
1
  import { type BehaviorSubject, type Observable } from "rxjs";
2
- /** Subscribe to the value of an observable */
2
+ /** A thing wrapper around useObservableState that allows undefined */
3
3
  export declare function useObservable<T extends unknown>(observable?: BehaviorSubject<T>): T;
4
4
  export declare function useObservable<T extends unknown>(observable?: Observable<T>): T | undefined;
@@ -1,7 +1,7 @@
1
1
  import { EventFactory } from "applesauce-factory";
2
2
  import { PropsWithChildren } from "react";
3
3
  export declare const FactoryContext: import("react").Context<EventFactory | undefined>;
4
- /** Provides an EventFactory to the component tree */
4
+ /** Provides an {@link EventFactory} to the component tree */
5
5
  export declare function FactoryProvider({ factory, children }: PropsWithChildren<{
6
6
  factory?: EventFactory;
7
7
  }>): import("react/jsx-runtime").JSX.Element;
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { createContext } from "react";
3
3
  export const FactoryContext = createContext(undefined);
4
- /** Provides an EventFactory to the component tree */
4
+ /** Provides an {@link EventFactory} to the component tree */
5
5
  export function FactoryProvider({ factory, children }) {
6
6
  return _jsx(FactoryContext.Provider, { value: factory, children: children });
7
7
  }
@@ -1,5 +1,5 @@
1
- import { EventStore, QueryStore } from "applesauce-core";
2
1
  import { PropsWithChildren } from "react";
2
+ import { EventStore, QueryStore } from "applesauce-core";
3
3
  export declare const QueryStoreContext: import("react").Context<QueryStore | null>;
4
4
  export declare const EventStoreContext: import("react").Context<EventStore | null>;
5
5
  /** Provides a EventStore to the component tree */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "applesauce-react",
3
- "version": "0.0.0-next-20250217154504",
3
+ "version": "0.0.0-next-20250217174538",
4
4
  "description": "React hooks for applesauce",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -48,10 +48,10 @@
48
48
  }
49
49
  },
50
50
  "dependencies": {
51
- "applesauce-accounts": "0.0.0-next-20250217154504",
52
- "applesauce-content": "0.0.0-next-20250217154504",
53
- "applesauce-core": "0.0.0-next-20250217154504",
54
- "applesauce-factory": "0.0.0-next-20250217154504",
51
+ "applesauce-accounts": "0.0.0-next-20250217174538",
52
+ "applesauce-content": "0.0.0-next-20250217174538",
53
+ "applesauce-core": "0.0.0-next-20250217174538",
54
+ "applesauce-factory": "0.0.0-next-20250217174538",
55
55
  "nostr-tools": "^2.10.4",
56
56
  "observable-hooks": "^4.2.4",
57
57
  "react": "^18.3.1",