-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Example usage without reagent? #35
Comments
@Lokeh there is a full implementation in CLJS, yes (haven't tested recently if it works; I know it was modified at one point). However That said it might not be terribly hard to hook up. |
Right, I think as long as I can make a reaction that triggers the React render, that would be enough. e.g.: https://github.com/Lokeh/hooks-demo/blob/master/src/hooks_demo/hooks.cljs#L41 Or even just using https://github.com/Lokeh/hooks-demo/blob/master/src/hooks_demo/hooks.cljs#L13 |
Haven't checked everything about the code you posted, but on first glance it looks reasonable to me! |
I'd like to take this one (several?) step further, and use the machinery in posh to be able to detect when queries change. I'm working on a simple forward-chaining rules system based on Datascript, currently just brute force evaluating every query from the LHS of rules on every transaction, obviously inefficient. Posh appears to at least partially address this, but I think I need to hook in at a lower level than a "reaction". What I probably want is to be able to transact data, then get the list of queries whose results have changed and the delta in query results. Looks like posh does at least some of this, so any pointers to help me avoid reinventing wheels appreciated. |
Line 121 in aeaa9c9
Line 198 in aeaa9c9
:tx-data and in posh/src/posh/lib/datom_matcher.cljc Line 24 in aeaa9c9
Not sure how it correlates patterns to queries, but that should at least get you most of the way. |
@Lokeh @alexandergunnarson I know this is an old thread, but I came across it as I was looking for a method to use https://github.com/tonsky/datascript and https://github.com/Lokeh/helix and the functionality posh provides obviously bridges the gap. I'm wondering if there is any examples of how to combine posh and helix? It looks like @denistakeda and @fpischedda are close to getting rum support added to posh and I wonder if a similar approach might work with helix too... ? |
Helo @xlfe . I know nothing of helix, but I'm sure |
helix doesn't really add anything on top of React (runtime) wise, so it doesn't include any additional tools for external state management. Reading the PR above, it looks like posh needs some 3rd party mechanism for creating and deriving from reactive atoms. That is outside the scope of helix. I am currently working on a stand alone library for that sort of reactive dataflow programming for external state, but I wouldn't suggest using it for now. I'm not sure what to recommend in the mean time, since both rum and reagent bundle their reactive atom code alongside their code for creating components, which obviously you don't want. You could try and use rum or reagent's reactive atom machinery and create a custom hook for interoping with them, but it might inflate your bundle size since it could include code that you won't use. I wish I had a better answer right now. Cheers! |
@xlfe Not sure how Helix works internally but when you say bridge Datascript and Posh with <React library of choice>, the place to look for extending Posh to other non-Reagent React libraries would be here: https://github.com/mpdairy/posh/blob/master/src/posh/reagent.cljs And this namespace provides a general reactive atom implementation, lifted from Reagent: https://github.com/mpdairy/posh/blob/master/src/posh/lib/ratom.cljc AFAIK Posh doesn't have anything out-of-the-box for this (seems like this lib hasn't changed much in a while), but it doesn't seem like an extraordinary effort to make it work. |
thanks all for responding! lots of food for thought. @Lokeh look forward to seeing where you go with helix and serenity @alexandergunnarson thanks for those tips I also came across some other relevant issues and projects |
I'm looking at integrating this with plain React + Hooks. So I'm, at the moment, missing the reactive bits that I would use to fill in
:ratom
and:make-reaction
.I could easily use the reagent plugin and wire it up to execute React updates on reset, but I'd rather not depend on reagent at all.
Is it possible to just use posh's
posh.lib.ratom
? I see it's used mainly for CLJ, but AFAICT it seems to be a full implementation in CLJS as well. Can anyone confirm it would suffice?The text was updated successfully, but these errors were encountered: