Coder Social home page Coder Social logo

zheksoon / dipole Goto Github PK

View Code? Open in Web Editor NEW
23.0 4.0 4.0 1.62 MB

dipole - tiny reactive state management that just works

Home Page: https://dipole.js.org

License: MIT License

JavaScript 0.68% TypeScript 99.32%
state-management observable reactive reactive-programming mobx react computed frp tfrp

dipole's People

Contributors

eugene-daragan-pandadoc avatar mindplay-dk avatar zheksoon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

dipole's Issues

Custom implementation of Set (HashSet)

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.

Manual clean-up

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? ๐Ÿ™‚

fromGetter?

Will you explain a usage for this utility? I was trying to grok it. Thanks!

Reaction arguments?

I was wondering about this line here:

return this._reaction.apply(this._context, arguments);

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?

Reaction run()

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.