AmpersandJS / examples

A collection of example apps/patterns using ampersand
MIT License
45 stars 16 forks source link

Question: how does the change event get triggered? #16

Closed alessioalex closed 9 years ago

alessioalex commented 9 years ago

Hey @latentflip I was just wondering how does the change event get triggered for the domthing example? I'm having a hard time understanding this. I've looked at ampersand-state but I'm either too tired or the change is not being triggered there. Thank you.

/cc @HenrikJoreteg

Thanks guys.

alessioalex commented 9 years ago

The confusing thing to me is that you are not using .set() to update the value, so I'm guessing you are probably using Object.defineProperty() with custom setters somewhere..?

alessioalex commented 9 years ago

Ah nevermind: https://github.com/AmpersandJS/ampersand-state/blob/master/ampersand-state.js#L560

My bad :+1:

latentflip commented 9 years ago

@alessioalex heads up that the future of domthing looks tentative :) it's probably unlikely it'll make a full production-quality release if I'm honest, as combining react + ampersand has probably a stronger future than I can support with domthing. But, feel free to play with it :)

alessioalex commented 9 years ago

To be honest I'm not too fond of React. I dislike JSX and writing all my template code in JavaScript. domthing might not be React, but it's simple and gets the job done.

I think the only thing I would change is making it render stuff with setImmediate or something, in case there are other changes in the same event loop tick: https://github.com/AmpersandJS/ampersand-domthing-mixin/blob/master/index.js#L8-L14

TL;DR Love the simplicity of Ampersand with this module, dislike React inliny templates.

@latentflip btw, are there any Ampersand with React examples? Would like to replicate an example with domthing.

latentflip commented 9 years ago

@alessioalex this already happens, it just happens within domthing. Renders are queued until the next requestAnimationFrame fires: https://github.com/latentflip/domthing/blob/master/lib/runtime/template.js#L35-L38

alessioalex commented 9 years ago

@latentflip thank you for your prompt feedback, really appreciate it. Well I guess this module is just perfect for some use cases then :D I'll go along and play with it :)