DEV Community

Discussion on: Building a Reactive Library from Scratch

Collapse
 
goldeli profile image
缪宇

I nested effects, but it also works fine. full code

Thread Thread
 
ryansolid profile image
Ryan Carniato • Edited

If you try to subscribe after the inner effect it doesn't track. Change the example to:

createEffect(() => {
  createEffect(() => {
    log("value is ", value());
  });
  log("name is ", name());
});
Enter fullscreen mode Exit fullscreen mode

Keep in mind this is just a simple approximation. I don't actually use an array in my libraries and instead just store the out context and then restore it.