Open stalniy opened 8 years ago
CC: @blikblum @Duder-onomy @Leeds-eBooks @mikeric @jccazeaux
Please pay attention that I do not propose to add custom expression parsers in rivets-core but instead I propose to create extensibility point. So, people who wants to use more complex expression can do that
Will a new (or extension of) parser be enough? If the parser decides it's an object, the binding mecanism will have have to know how to handle an object. Currently binding can only handle primitives and keypath types. Is it really possible with only an extension point ?
@jccazeaux
yes, it's possible. So, look at the definition rv-popover="enabled: user.isActive, template: myTemplate"
. We want to subscribe to values of the object declaration and compute a new object each time any of its values are changed. And values are basically keypaths or primitives which rivets are able to parse
@stalniy I read again your proposal, I didn't understand it well, it's clear now :wink: I like your example, handling objects could be usefull and not so hard to do. Is it really necessary to open an extension point ?
Currently only keypath expressions and primitives can be passed as parameters to both components' attributes and binders value. I suggest to allow users to extend this functionality. So, I for example want to pass an object to binder:
Proposal:
Rivets.TypeParser
.addExpressionSupport
which accepts an object withparse
method. Adds expression parser to top of the expression parsers stackparse
method for each expression object. If something is returned then stop iteration. We know how to parse this stringparse
method will be and object which haskeypaths
property (our observable dependencies) andevaluate
method calling which the result of the expression can be retrievedThat will allow devs to extend existing expressions with own a bit more advanced as I showed in popover example or even substitute parser with its own (or custom) implementation.