Skip to content

Commit 3770426

Browse files
committed
Add more info about solid usage
1 parent 64be66b commit 3770426

File tree

1 file changed

+44
-12
lines changed

1 file changed

+44
-12
lines changed

used-solid.md

Lines changed: 44 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
- `solid.$PROXY` is used to check if the props object is a proxy
66

77
- 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.
8-
- https://github.com/thetarnav/solid-devtools/blob/main/packages/debugger/src/inspector/inspector.ts#L98-L113
8+
- [source code](https://github.com/thetarnav/solid-devtools/blob/main/packages/debugger/src/inspector/inspector.ts#L98-L113)
99
- `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.
1010

1111
- For proxy props I can only get keys with `Object.keys(props)`
@@ -20,7 +20,7 @@
2020

2121
- so currently I cannot intercept the initial reads from props—which are the most common
2222
- I would have to do `Object.defineProperty(owner, "props", {set})` to be able to patch props before component function executes probably
23-
- https://github.com/solidjs/solid/blob/main/packages/solid/src/reactive/signal.ts#L1115-L1133
23+
- [source code](https://github.com/solidjs/solid/blob/main/packages/solid/src/reactive/signal.ts#L1115-L1133)
2424

2525
## Store
2626

@@ -29,32 +29,63 @@
2929
- `store.isWrappable()`
3030

3131
- `store.DEV.hooks.onStoreNodeUpdate()` for observing changes to stores
32-
- https://github.com/thetarnav/solid-devtools/blob/main/packages/debugger/src/inspector/store.ts#L27-L49
32+
- [source code](https://github.com/thetarnav/solid-devtools/blob/main/packages/debugger/src/inspector/store.ts#L27-L49)
3333

3434
### Issues
3535

36-
- 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`
36+
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`.
3838

39-
## Owner tree
39+
## Roots
4040

4141
- `solid.DEV.hooks.afterCreateOwner()` for attaching the debugger to roots
4242
- to gather top-level roots like `render()`
4343
- but also to "re-attach roots back to the owner tree" when `createRoot` is used under owners, like in `mapArray`
44-
- https://github.com/thetarnav/solid-devtools/blob/main/packages/debugger/src/main/roots.ts#L147-L163
44+
- [source code](https://github.com/thetarnav/solid-devtools/blob/main/packages/debugger/src/main/roots.ts#L147-L163)
4545
- access to `owner.owner` and `owner.cleanups` to listen to parent's *(root's detached owner)* cleanup
4646
- so that if the root's parent disposes before the root, the root will need to be "reattached" to first found "alive" owner
4747
- this is rather uncommon
4848

49-
- patching `owner.cleanups` to listen to cleanup of any owner
50-
- https://github.com/thetarnav/solid-devtools/blob/main/packages/debugger/src/main/utils.ts#L205-L227
49+
### Issues
50+
51+
Any root created before `solid.DEV.hooks.afterCreateOwner` is set will be missed.\
52+
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+
If there was access to any unowned root, the extension would work with any solid app with no setup.
54+
55+
## Node types
56+
57+
By node I mean any solid internal object, like owners, signals, roots, store-nodes, and anything user registers with `solid.DEV.registerGraph()`.
58+
59+
There are many internal owner properties that are inspected to determine kind of node.
60+
- [source code](https://github.com/thetarnav/solid-devtools/blob/main/packages/debugger/src/main/utils.ts#L5-L86)
61+
62+
### Issues
63+
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.
65+
66+
## Owners
67+
68+
patching `owner.cleanups` to listen to cleanup of any owner
69+
- [source code](https://github.com/thetarnav/solid-devtools/blob/main/packages/debugger/src/main/utils.ts#L205-L227)
70+
71+
### Issues
72+
73+
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+
75+
## Computation updates
76+
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)
78+
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
81+
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)
5183

52-
- `owner.owned`
5384

5485
## Computations
5586

56-
- `owner.value` + patching the value
57-
- `owner.sources`
87+
- `owner.owned`
88+
5889
- `owner.observers`
5990

6091
## Source Map
@@ -64,6 +95,7 @@
6495
- `owner.sourceMap`
6596

6697
## List
98+
6799
- `solid.$PROXY` in [props](#props)
68100
- `Object.defineProperty(props, key, {get})` in [props](#props)
69101
- `solid.getListener() + solid.onCleanup()` in [props](#props)

0 commit comments

Comments
 (0)