You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: solid-usage.md
+66-39Lines changed: 66 additions & 39 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,40 +1,36 @@
1
1
# Current usage
2
2
3
-
## Props
4
-
5
-
-`solid.$PROXY` is used to check if the props object is a proxy
3
+
## Node types
6
4
7
-
- If it's not a proxy, I can patch it with `Object.defineProperty(props, key, {get})` to intercept accessing props—since accessing props might cause side-effects I have to wait for the user.
- `solid.getListener() + solid.onCleanup()` is useful there to know when the prop is no longer being listened to—I might not have the latest value anymore.
5
+
By node I mean any solid internal object, like owners, signals, roots, store-nodes, and anything user registers with `solid.DEV.registerGraph()`.
10
6
11
-
- For proxy props I can only get keys with `Object.keys(props)`
7
+
There are many internal owner properties that are inspected to determine kind of node. — [source code](https://github.com/thetarnav/solid-devtools/blob/main/packages/debugger/src/main/utils.ts#L5-L86)
12
8
13
9
### Issues
14
10
15
-
- I cannot intercept proxy props—users just see `foo: unknown` without the value
11
+
This is super brittle, some properties are set some time after the owner is created, most of the properties accessed are not used for anything else.
16
12
17
-
- props object cannot be changed, just monkeypatched—replacing it would probably let me intercept reads to proxy props
13
+
## Node names
18
14
19
-
-`solid.DEV.hooks.afterCreateOwner()` gets called before `props` are attached to the owner, so I cannot get to them then.
15
+
-`owner.name` or `signal.name` or `owner.component.name` or `owner.component.displayName`
20
16
21
-
- so currently I cannot intercept the initial reads from props—which are the most common
22
-
- I would have to do `Object.defineProperty(owner, "props", {set})` to be able to patch props before component function executes probably
There is no connection between signals and the store-nodes they are being used in.\
37
-
So if there is an effect that listens to some store property *(e.g. `createEffect(() => store.foo)`)*, from devtools perspective this is just some random signal being observed in `owner.sources`.
29
+
```ts
30
+
if (isDev) {
31
+
getOwner()!.name="Foo.Bar"
32
+
}
33
+
```
38
34
39
35
## Roots
40
36
@@ -52,41 +48,72 @@ Any root created before `solid.DEV.hooks.afterCreateOwner` is set will be missed
52
48
This is annoying because the extension's content-script isn't garanteed to run before user scripts. Making the `solid-devtools` npm package and `import "solid-devtools"` required to capture all the roots.\
53
49
If there was access to any unowned root, the extension would work with any solid app with no setup.
54
50
55
-
## Node types
51
+
## Computation updates
56
52
57
-
By node I mean any solid internal object, like owners, signals, roots, store-nodes, and anything user registers with `solid.DEV.registerGraph()`.
53
+
-`owner.fn` is patched to observe when the computration reruns — [source code](https://github.com/thetarnav/solid-devtools/blob/main/packages/debugger/src/main/observe.ts#L50-L88)
58
54
59
-
There are many internal owner properties that are inspected to determine kind of node.
-`owner.value` is read to get the current owner value and patched to listen to changes — [source code](https://github.com/thetarnav/solid-devtools/blob/main/packages/debugger/src/main/observe.ts#L98-L123)
56
+
- signals are being observed the same way
57
+
- this is also separate from observing `owner.fn` because not every rerun will cause the value to update *(thanks to `equals` option)*
61
58
62
-
### Issues
59
+
-`owner.sources` — by listening to each of the sources, I'm able to tell which source caused the computation to rerun. — [source code](https://github.com/thetarnav/solid-devtools/blob/main/packages/logger/src/index.ts#L117-L180)
63
60
64
-
This is super brittle, some properties are set some time after the owner is created, most of the properties accessed are not used for anything else.
61
+
## Owners tree
62
+
63
+
Reads `owner.owner` and `owner.owned` to walk the tree in both directions
65
64
66
-
## Owners
65
+
## Owner disposing
67
66
68
-
patching `owner.cleanups` to listen to cleanup of any owner
Patching `owner.cleanups` to listen to cleanup of any owner — [source code](https://github.com/thetarnav/solid-devtools/blob/main/packages/debugger/src/main/utils.ts#L205-L227)
70
68
71
69
### Issues
72
70
73
71
The cleanups are executed depth first—if I try to walk the tree on child's cleanup, I cannot tell if the parent is getting cleaned up as well or not. There is no `isDisposed` property.
74
72
75
-
## Computation updates
73
+
## Dependency graph
76
74
77
-
-`owner.fn` is patched to observe when the computration reruns — [source code](https://github.com/thetarnav/solid-devtools/blob/main/packages/debugger/src/main/observe.ts#L50-L88)
75
+
-`owner.sources` and `owner.observers`
78
76
79
-
-`owner.value` is read to get the current owner value and patched to listen to changes — [source code](https://github.com/thetarnav/solid-devtools/blob/main/packages/debugger/src/main/observe.ts#L98-L123)
80
-
- signals are being observed the same way
77
+
-`sourceValue.graph` — for signals to know to which owner they "belong to"
81
78
82
-
-`owner.sources` — by listening to each of the sources, I'm able to tell which source caused the computation to rerun. — [source code](https://github.com/thetarnav/solid-devtools/blob/main/packages/logger/src/index.ts#L117-L180)
79
+
## Props
80
+
81
+
-`solid.$PROXY` is used to check if the props object is a proxy
82
+
83
+
- If it's not a proxy, I can patch it with `Object.defineProperty(props, key, {get})` to intercept accessing props—since accessing props might cause side-effects I have to wait for the user.
- `solid.getListener() + solid.onCleanup()` is useful there to know when the prop is no longer being listened to—I might not have the latest value anymore.
86
+
87
+
- For proxy props I can only get keys with `Object.keys(props)`
88
+
89
+
### Issues
90
+
91
+
- I cannot intercept proxy props—users just see `foo: unknown` without the value
92
+
93
+
- props object cannot be changed, just monkeypatched—replacing it would probably let me intercept reads to proxy props
83
94
95
+
-`solid.DEV.hooks.afterCreateOwner()` gets called before `props` are attached to the owner, so I cannot get to them then.
96
+
97
+
- so currently I cannot intercept the initial reads from props—which are the most common
98
+
- I would have to do `Object.defineProperty(owner, "props", {set})` to be able to patch props before component function executes probably
-`store.unwrap()` with type reflection when serializing and reading stores
84
104
85
-
## Computations
105
+
-`store.isWrappable()`
106
+
107
+
-`store.DEV.hooks.onStoreNodeUpdate()` for observing changes to stores — [source code](https://github.com/thetarnav/solid-devtools/blob/main/packages/debugger/src/inspector/store.ts#L27-L49)
86
108
87
-
-`owner.owned`
109
+
### Issues
88
110
89
-
-`owner.observers`
111
+
There is no connection between signals and the store-nodes they are being used in.\
112
+
So if there is an effect that listens to some store property *(e.g. `createEffect(() => store.foo)`)*, from devtools perspective this is just some random signal being observed in `owner.sources`.
0 commit comments