-
-
Notifications
You must be signed in to change notification settings - Fork 98
feat(decorator-observable): support coerce value #612
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
Conversation
|
oh, this PR looks a lot like aurelia/templating#558 - @bigopon, could You take a look at the comments i wrote there (don't want to duplicate them here) |
|
The coerces module will be moved to |
|
Yes, actually i understood it (saw the related comments from other PR) - just didn't express myself very clearly with previous comment ;) |
|
@atsu85 thanks for the review, I've put some response 😄 |
|
Demo of the decorators (incomplete) Gist The basic work on coerce is done, (which is the easier part), but when integrated with I've been looking into the ast to see if there is any easy solution that I can do, but no luck so far. One thing I thought of is to iterate through the subscribers and add @jdanyow @EisenbergEffect @atsu85 Would love to have some help on this. |
|
@bigopon, sadly i'm not familiar enough with the codebase, to help You to get moving again |
|
Is there a issue this PR fixes? I'm trying to refresh my memory on the backstory for this change. |
|
This is the original issue aurelia/templating#96 Where you suggested the This is my first attempt aurelia/templating#558 Where I tried to introduce naive coerce function into This is my lastest try with type coercion https://gist.run/?id=ad523ef690e40e9c5cde123cd0c532fa Where it doesn't update DOM node again after coercing value from element input event, such as input. I also described the attempt in detail in gitter, but wouldn't mind if I need to repeat it here. TL;DR: the main requirement I couldn't overcome (completely) was the ability to not trigger update DOM again after getting the value from event, converting it and assign via setValue. |
|
@jdanyow This is related to the other PR I just pinged you on. |
|
I messed up my master branch so this commit is gone. Will reopen if necessary and after we sort out how to deal with |
This PR adds coerce support for decorator
observable.Usage:
With normal syntax
Using metadata
TypeScript users can achieve above result (metadata) by simpler code:
Remember to instruct the compiler to emit decorator metadata TypeScript decorator doc
All coerce type will be resolved to a string, which then is used to get the converter function in
coercesexport of this module. So, to extend or modify basic implementations:For TS users or JS users who want to use metadata, to extend coerce mapping:
With fluent syntax
To built your own fluent syntax observable:
@EisenbergEffect The core is in
coerce.js(original PR)