File tree Expand file tree Collapse file tree 5 files changed +151
-0
lines changed Expand file tree Collapse file tree 5 files changed +151
-0
lines changed Original file line number Diff line number Diff line change 21
21
<li ><a href =" /storage/upload-task" ><UploadTask></a ></li >
22
22
<li ><a href =" /storage/download-url" ><DownloadURL></a ></li >
23
23
<li ><a href =" /storage/storage-list" ><StorageList></a ></li >
24
+ <li class =" heading" >realtime db</li >
25
+ <li ><a href =" /rtdb/node-store" >nodeStore</a ></li >
26
+ <li ><a href =" /rtdb/node-list-store" >nodeListStore</a ></li >
27
+ <li ><a href =" /rtdb/node-component" ><Node></a ></li >
28
+ <li ><a href =" /rtdb/node-list-component" ><NodeList></a ></li >
24
29
<li class =" heading" >analytics</li >
25
30
<li ><a href =" /guide/todo" ><PageView></a ></li >
26
31
</ul >
Original file line number Diff line number Diff line change
1
+ ---
2
+ title : Node Component
3
+ pubDate : 2023-07-23
4
+ description : SvelteFire Node Component API reference
5
+ layout : ../../layouts/MainLayout.astro
6
+ ---
7
+
8
+ # Node
9
+
10
+ The ` Node ` component is a wrapper around the ` nodeStore ` . It renders the node data and handles the loading state.
11
+
12
+ ### Props
13
+
14
+ - ` path ` - RealtimeDB path string (e.g. ` posts/hi-mom ` )
15
+ - ` startWith ` - (optional) initial value to use before the data is fetched
16
+
17
+ ### Slots
18
+
19
+ - ` default ` - The node data
20
+ - ` loading ` - Loading state
21
+
22
+ ### Slot Props
23
+
24
+ - ` data ` - The node data
25
+ - ` path ` - The Database reference
26
+ - ` rtdb ` - The Database instance
27
+
28
+ ### Example
29
+
30
+ ``` svelte
31
+ <script>
32
+ import { Node } from 'sveltefire';
33
+ </script>
34
+
35
+ <Node path={'posts/id'} let:data>
36
+ <p>{data?.title}</p>
37
+
38
+ <p slot="loading">Loading...</p>
39
+ </Node>
40
+ ```
Original file line number Diff line number Diff line change
1
+ ---
2
+ title : NodeList Component
3
+ pubDate : 2023-07-23
4
+ description : SvelteFire NodeList Component API reference
5
+ layout : ../../layouts/MainLayout.astro
6
+ ---
7
+
8
+ # NodeList
9
+
10
+ The ` NodeList ` component is a wrapper around the ` nodeListStore ` . It renders the node list data and handles the loading state.
11
+
12
+ ### Props
13
+
14
+ - ` path ` - RealtimeDB reference
15
+ - ` startWith ` - (optional) initial value to use before the collection is fetched
16
+
17
+ ### Slots
18
+
19
+ - ` default ` - The node list data
20
+ - ` loading ` - Loading state
21
+
22
+ ### Slot Props
23
+
24
+ - ` data ` - An array of nodes
25
+ - ` ref ` - The Database node reference
26
+ - ` rtdb ` - The Database instance
27
+ - ` count ` - The number of nodes returned by the query
28
+
29
+ ### Example
30
+
31
+ ``` svelte
32
+ <script>
33
+ import { NodeList } from 'sveltefire';
34
+ </script>
35
+
36
+ <NodeList path={'posts'} let:data let:count>
37
+
38
+ <p>Found {count} posts</p>
39
+
40
+ {#each data as post}
41
+ <p>{post.title}</p>
42
+ {/each}
43
+
44
+ <p slot="loading">Loading...</p>
45
+ </NodeList>
46
+ ```
Original file line number Diff line number Diff line change
1
+ ---
2
+ title : nodeListStore
3
+ pubDate : 2023-11-23
4
+ description : SvelteFire nodeStore API reference
5
+ layout : ../../layouts/MainLayout.astro
6
+ ---
7
+
8
+ # nodeListStore
9
+
10
+ Subscribes to RealtimeDB node list data and listens to real-time updates.
11
+
12
+ ### Parameters
13
+
14
+ - ` rtdb ` - RealtimeDB instance
15
+ - ` path ` - A RealtimeDB path string (e.g. ` posts ` )
16
+ - ` startWith ` - (optional) initial value to use before the data is fetched
17
+
18
+ ### Example
19
+
20
+ ``` svelte
21
+ <script>
22
+ import { nodeListStore } from 'sveltefire';
23
+ import { rtdb } from '$lib/firebase'; // your rtdb instance
24
+
25
+ const posts = nodeListStore(rtdb, 'posts');
26
+ </script>
27
+
28
+ {#each $posts as post}
29
+ <p>{post.title}</p>
30
+ {/each}
31
+ ```
Original file line number Diff line number Diff line change
1
+ ---
2
+ title : nodeStore
3
+ pubDate : 2023-11-23
4
+ description : SvelteFire nodeStore API reference
5
+ layout : ../../layouts/MainLayout.astro
6
+ ---
7
+
8
+ # nodeStore
9
+
10
+ Subscribes to RealtimeDB node and listens to realtime updates.
11
+
12
+ ### Parameters
13
+
14
+ - ` rtdb ` - RealtimeDB instance
15
+ - ` path ` - A RealtimeDB path string (e.g. ` posts/hi-mom ` )
16
+ - ` startWith ` - (optional) initial value to use before the data is fetched
17
+
18
+ ### Example
19
+
20
+ ``` svelte
21
+ <script>
22
+ import { nodeStore } from 'sveltefire';
23
+ import { rtdb } from '$lib/rtdb'; // your RealtimeDB instance
24
+
25
+ const post = nodeStore(rtdb, 'posts/id');
26
+ </script>
27
+
28
+ {$post?.title}
29
+ ```
You can’t perform that action at this time.
0 commit comments