zheksoon / dipole Goto Github PK
View Code? Open in Web Editor NEWdipole - tiny reactive state management that just works
Home Page: https://dipole.js.org
License: MIT License
dipole - tiny reactive state management that just works
Home Page: https://dipole.js.org
License: MIT License
As covered in the documentation, you have to manually .run()
a reaction the first time:
const r = reaction(() => {
console.log(`Sum of ${a.get()} and ${b.get()} is ${sum.get()}`)
})
r.run() // first run should be triggered manually
The documentation doesn't really explain why that is?
The thing that puzzles me is, what do you actually have, if you haven't called the run
method yet?
You don't really have a reaction yet - if it hasn't run the function, it doesn't know the function's dependencies, and so it can't actually react to anything yet.
When is an "inactive" reaction useful? Or why isn't the reaction automatically run the first time?
Thanks for this awesome lib! https://gist.github.com/mrjjwright/43d3ddf4830fb8d6bb3085b5652f9221
Hi,
Just wondering, why do you use a custom implementation of HashSet
?
I noticed it says in your README, "ES3 compatibility - should work even in a very old browsers" - so maybe that's why?
Still, the standard Set
is in all browsers since 6+ years, so I wonder.
Either way, what do you think about a "ponyfill" approach instead?
That is, make your HashSet
constructor and methods compatible with standard Set
methods, so that you can produce two different builds? e.g. two builds, one of them smaller (and probably faster) for modern browsers.
I was wondering about this line here:
Line 327 in 34e64ae
What is arguments
for?
As far as I can tell, arguments
will be empty, since run()
does not accept any arguments.
There are no calls to run()
on a Reaction
in user code, right?
Or is there a use-case where manager
might pass arguments to run()
, which would get forwarded?
Will you explain a usage for this utility? I was trying to grok it. Thanks!
Hey,
This library is interesting as as state management solution for React/Preact - but I'm really interested in using this library to create a truly reactive UI library, one that doesn't diff virtual DOM nodes, along the lines of Sinuous.
I cobbled together a working prototype last night, and this was surprisingly easy:
https://codesandbox.io/s/reactive-dom-lol-rrtd4?file=/src/index.jsx
The problem is, this leaks listeners like crazy - if you make a few changes to the input value, and then toggle the checkbox, you can see the "LOL" messages piling up in the console. Reactions aren't getting garbage-collected, presumably because they internally reference the observables they're listening to.
From the documentation, I understand I'd have to manually destroy()
the reactions to free them - which I've tried to do, but suddenly everything is much more complex than it seems on the surface, as I basically have to manually manage the whole create/update/destroy life-cycle using code.
I could be wrong, but I don't think S.js has this issue? Not sure.
I wonder if there would be something we can do with WeakMap
to enable garbage-collection of reactions - or maybe avoid keeping subscriber references by decoupling their relations through a message bus or something?
I honestly don't understand the theory behind it all, I just know I like it. ๐
Is this something you're interested in at all, or is this mostly a state management library to you? ๐
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.