-
Notifications
You must be signed in to change notification settings - Fork 149
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
Basic protocol support for vanilla JS objects via mori.extend #108
base: master
Are you sure you want to change the base?
Conversation
Updated the entry point as mentioned tgriesser@c46eb42#commitcomment-7496107 |
Hey guys, is this pull request scheduled for a merge at any point? |
@eborden it needs to be updated to be a bit more flexible. |
Any specific pointers on what I could do to update it? It's been working quite well for me (aside from the js->clj issue - http://dev.clojure.org/jira/browse/CLJS-842) |
I'm currently using tgriesser's patch and it is working quite nicely. I'm also curious what added flexibility you see a need for. |
@swannodette it looks pretty solid to me, and given that it allows @tgriesser to implement cursors, seems good enough reason to include this PR. Looking at your recent benchmarks against immutable.js, it makes want to make the switch, but... no cursors, no go for us. |
@swannodette went ahead and updated with master if you wanted to take another look. @skrat the "cursors" I implemented in that gh repo are definitely subpar and I'm not really planning on maintaining them. So I'm not sure I'd recommend using that implementation in anything serious, but it does demonstrate a proof of concept of using custom persistent data structures from mori which is pretty neat. |
I wonder whether a library that exposes ClojureScript's atom and Om's cursors wouldn't be a better solution, that way the maintenance problem would be solved by having a simple wrapper. The meat would be implemented in well established and actively maintained projects. |
@skrat This PR has other uses other than implementing cursors, such as utilizing complex types in Maps and Sets. |
Adds basic support for extending several protocols to vanilla JS objects via
mori.extend
The protocols included thusfar:
IAssociative
,ICloneable
,ICollection
,ICounted
,IEncodeClojure
,IEncodeJS
,IEquiv
,IHash
,IKVReduce
,ILookup
,IMap
,ISeq
,ISeqable
Real world use case: https://github.com/tgriesser/mori-cursors
Currently, adding a protocol looks something like:
However I'm wondering whether it'd be more concise to assume the object provided as the second arg to
extend
implements specific protocol functions, so you could just say:or just
Also, the
IEncodeClojure
is currently pretty useless, but would become useful with the proposed change here (or similar): http://dev.clojure.org/jira/browse/CLJS-842