Twitter | Search | |
Sander Elias @🇳🇱
I'm in 😍 with Ivy! ♥♥♥ It finally enabled me to write an custom decorator to make observable life-cycle hooks. No more need of adding placeholder `ngOnxxx` the code below is actually working code. Once ivy is released I will release this too! 🎉🎉🔥🔥🎉🎉
Reply Retweet Like More
Trotyl Yu Dec 19
Not quite true, static properties are all being evaluated before decorators, and lifecycle hooks are determined eagerly under `defineComponent` call. The only way is to alter the result of `ngComponentDef`, which typed as `never` and not a public API, otherwise it's JIT-only.
Reply Retweet Like
Sander Elias @🇳🇱 Dec 19
Replying to @trotylyu @angular
I'm running in AOT mode.
Reply Retweet Like
Trotyl Yu Dec 20
Then it's touching internal APIs, isn't it?
Reply Retweet Like
Sander Elias @🇳🇱 Dec 20
Replying to @trotylyu @angular
Yes, it is.
Reply Retweet Like
Trotyl Yu Dec 20
That makes sense, but I don't think it could work with `ngOnChanges`.
Reply Retweet Like
Sander Elias @🇳🇱 Dec 20
Replying to @trotylyu @angular
Not 100% sure yet, but I have good hopes for that. Needs some extra handling tho.
Reply Retweet Like
Aslan Vatsaev 🇫🇷 🥨 Dec 18
Is this documented?
Reply Retweet Like
Sander Elias @🇳🇱 Dec 18
Replying to @avatsaev @angular
No. Ivy isn't ready yet, and my decorator can't be released before that, so there is little use in my documenting it ,😁
Reply Retweet Like
Dominic Elm in 🏴󠁧󠁢󠁥󠁮󠁧󠁿 Dec 19
Why not? You can release your tiny hooks lib as alpha as well? Or beta release or something along those lines. Would be great if peopel could already try this out and give you feedback :)
Reply Retweet Like
Sander Elias @🇳🇱 Dec 20
Perhaps once I have some mileage on it. It's a bit too dependant on internals right now
Reply Retweet Like
Sander Elias @🇳🇱 Dec 18
Next on my list.
Reply Retweet Like
Sander Elias @🇳🇱 Dec 18
Already works with my current decorator.
Reply Retweet Like
Cyrille Tuzi Dec 19
Would be interested by the decorator code. I'm thinking of an Async decorator for some time, to launch change detection automatically for data coming from HTTP requests, and then get rid of zonejs. Do you think it's possible?
Reply Retweet Like
Sander Elias @🇳🇱 Dec 20
Replying to @cyrilletuzi @angular
No need for a decorator there! As your http is already a stream, you can just tap into it. Even better, use the async pipe there too, as it does an `markForChecked` However, you need more as that to be able to drop zonejs. Running `detectChanges` on every 'next' will kill perf.
Reply Retweet Like
little chaosmonster Dec 18
The second thing I am really looking forward to with Ivy is mixins
Reply Retweet Like
Sander Elias @🇳🇱 Dec 18
Well, true mixins are still a issue. As long as it's next to impossible to tell TS you changed the prototype of anything, its not going. My next 2 will be: 1. `@FromEvent(selector,'click') button$: Observable<event>` 2. `@UnSubOnDestroy() sub = s$.subscribe()`
Reply Retweet Like
little chaosmonster Dec 19
Number 1. looks like a kind of solution to the really old hot vs cold observable issue in templates. That issue looked into the same thing on a template level. That said, what I do not like about your approach is that is decoupled from the template. Still very impressive
Reply Retweet Like