@rivetkit/framework-base 2.3.0-rc.1 → 2.3.0-rc.10
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/package.json +2 -2
- package/README.md +0 -86
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rivetkit/framework-base",
|
|
3
|
-
"version": "2.3.0-rc.
|
|
3
|
+
"version": "2.3.0-rc.10",
|
|
4
4
|
"description": "Base framework utilities for RivetKit client integrations",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"keywords": [
|
|
@@ -42,6 +42,6 @@
|
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@tanstack/store": "^0.7.1",
|
|
44
44
|
"fast-deep-equal": "^3.1.3",
|
|
45
|
-
"rivetkit": "2.3.0-rc.
|
|
45
|
+
"rivetkit": "2.3.0-rc.10"
|
|
46
46
|
}
|
|
47
47
|
}
|
package/README.md
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
# RivetKit Framework Base
|
|
2
|
-
|
|
3
|
-
_Library to build and scale stateful workloads_
|
|
4
|
-
|
|
5
|
-
[Learn More →](https://github.com/rivet-dev/rivet)
|
|
6
|
-
|
|
7
|
-
[Discord](https://rivet.dev/discord) — [Documentation](https://rivetkit.org) — [Issues](https://github.com/rivet-dev/rivet/issues)
|
|
8
|
-
|
|
9
|
-
## Lifecycle
|
|
10
|
-
|
|
11
|
-
### Mount
|
|
12
|
-
|
|
13
|
-
```
|
|
14
|
-
1. useActor(opts) called in React component
|
|
15
|
-
|
|
16
|
-
2. getOrCreateActor(opts)
|
|
17
|
-
- hash opts to get key
|
|
18
|
-
- sync opts to store (create or update actor entry)
|
|
19
|
-
- if not in cache:
|
|
20
|
-
- create Derived (subscribes to store)
|
|
21
|
-
- create Effect (handles connection logic)
|
|
22
|
-
- add to cache with refCount=0
|
|
23
|
-
- return { mount, state }
|
|
24
|
-
|
|
25
|
-
3. useEffect runs mount()
|
|
26
|
-
- cancel any pending cleanup timeout
|
|
27
|
-
- refCount++
|
|
28
|
-
- if refCount == 1:
|
|
29
|
-
- mount derived and effect
|
|
30
|
-
- if enabled and idle: call create() directly
|
|
31
|
-
(Effect only runs on state changes, not on mount)
|
|
32
|
-
|
|
33
|
-
4. Effect triggers (on state changes)
|
|
34
|
-
- if disabled and connected: dispose connection, reset to idle
|
|
35
|
-
- if enabled and idle: call create()
|
|
36
|
-
|
|
37
|
-
5. create()
|
|
38
|
-
- set connStatus = Connecting
|
|
39
|
-
- handle = client.getOrCreate(name, key)
|
|
40
|
-
- connection = handle.connect()
|
|
41
|
-
- subscribe to connection status/error events
|
|
42
|
-
- store handle and connection in store
|
|
43
|
-
|
|
44
|
-
6. Connection established
|
|
45
|
-
- connStatus updates, Derived updates, React re-renders
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
### Unmount
|
|
49
|
-
|
|
50
|
-
```
|
|
51
|
-
1. Component unmounts
|
|
52
|
-
2. useEffect cleanup runs
|
|
53
|
-
3. refCount--
|
|
54
|
-
4. if refCount == 0: setTimeout(cleanup, 0)
|
|
55
|
-
5. When timeout fires:
|
|
56
|
-
- if refCount > 0: skip (was remounted)
|
|
57
|
-
- else: dispose connection, remove from store/cache
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
### React Strict Mode
|
|
61
|
-
|
|
62
|
-
Why `setTimeout` matters:
|
|
63
|
-
|
|
64
|
-
```
|
|
65
|
-
- render
|
|
66
|
-
- mount: refCount = 1
|
|
67
|
-
- unmount: refCount = 0, schedule timeout
|
|
68
|
-
- remount: refCount = 1, cancel timeout
|
|
69
|
-
- timeout fires: refCount > 0, cleanup skipped
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
### Shared Actor
|
|
73
|
-
|
|
74
|
-
Two components using the same actor opts:
|
|
75
|
-
|
|
76
|
-
```
|
|
77
|
-
- Component A mounts: refCount = 1, connection created
|
|
78
|
-
- Component B mounts: refCount = 2, reuses connection
|
|
79
|
-
- Component A unmounts: refCount = 1, no cleanup
|
|
80
|
-
- Component B unmounts: refCount = 0, cleanup scheduled
|
|
81
|
-
- Timeout fires: connection disposed, removed from cache
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
## License
|
|
85
|
-
|
|
86
|
-
Apache 2.0
|