Vianney,
I haven't replied for the same reason other haven't... not a lot of time and a
lack of understanding your proposal. I also don't want to sound like a broken
record - I've posted to this list previously about this and figured I'd "stand
down" to spare everyone the repetition.
However, for those who are new to the list and have not heard of Clara before,
read on. Everyone else can press delete as they see fit.
The one other approach I would suggest you look into is the Clara library. It
is a rule engine that works efficiently with small changes to large amounts of
data/rules. You can think of a rule as an efficient means of creating
materialized views except that they only fire when new data matches (including
unification) with existing data/rule patterns.
It takes a little getting used to in a similar way that reactive programming
inverts control as compared to imperative logic. The typical use would be:
1) Insert new data into existing Clara session (stored in app state)
2) Fire rules (only rules matching the new data), possibly changing the session
state.
3) Store the resulting session value back into your app state.
4) Rinse, repeat.
For example, this might look like:
(reset! app-state (-> @app-state
(insert (->PurchaseOrder 123 "PO: 123"))
(insert (->ApprovalRequest 123 false))
(fire-rules)))
Note: app-state is an atom that holds a Clara session/db. Also, you can use
Clojure records as is done above or just plain maps, provided you supply Clara
with a function that can tell one map "type" from another.
The fire-rules function will run any rules that have been "activated" by
previous data insertions or removals and can have side effects on the rest of
the system (e.g. update the DOM, redraw React components, etc.)
A rule that matches the above facts might look (something) like this:
(defrule approve-po-request
[?po <- PurchaseOrder (== ?id id)] ; ?id variable "bound" to value of id
[?request <- ApprovalRequest (== ?id id)] ; Bound ?id variable used to unify
=>
(insert! (approve ?request)))
Negation is also possible in a LHS pattern. See the Clara docs for more info.
http://www.clara-rules.org
Clara also has queries (that share the same LHS syntax as rules) so that you
can get a snapshot of your state/session. This syntax is declarative and
similar to datalog and/or core.logic syntax.
I'm currently working to integrate Clara with Om Next (among other things) in
the same way DataScript has been. I don't have anything concrete to give you
but I'm sure if you squint you can see the possibilities. I had it integrated
it with other ClojureScript/React libraries but when Om Next came out I changed
course and started over.
However, if you just need DataScript/Datomic integration and don't need the
power of a rule based system, going with the existing Om Next integration will
be the simplest path forward. Rule engines have their own cognitive overhead
that some find unacceptable or that doesn't match with their coding style. To
each their own... YMWV.
Good luck!
Alan
On Thursday, December 3, 2015 at 6:40:56 AM UTC-8, Vianney Stroebel (vibl)
wrote:
> I posted an idea for a reactive and faster alternative to Datascript:
>
> https://github.com/tonsky/datascript/issues/132
>
> It seems too good to be true on paper so I probably have overlooked things.
>
> Comments are welcome!
>
> Vianney
--
Note that posts from new members are moderated - please be patient with your
first post.
---
You received this message because you are subscribed to the Google Groups
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/clojurescript.