Re:React-cursor: a JavaScript implementation of the Cursor c...
by STRML on Tuesday September 23, 2014 @12:27PM
(#8356168)
I agree, the naming is odd. `onChange` is almost always the name of a function that is called by a user event and passed an Event object, not called by the programmer and passed a raw value. Is it supposed to be used as the first line in a form onChange handler? Perhaps something like
onChange: function(e) { this.cursor.onChange(e.value);}
Even in that case, I think it is a lot more intuitive to use a function name like `change`, `mutate`, or `transact`. Personally, `onChange` is something I want to assign, not something I want to call. Additionally, it doesn't look like it can be passed a raw Event object, so you can't shorthand it in a render method and avoid creating an onChange callback.
Re:React-cursor: a JavaScript implementation of the Cursor c...
by trevex on Tuesday September 23, 2014 @02:30PM
(#8357165)
I agree. The first minute I looked through the tutorial `onChange` confused me, because I expected it to take a callback.
I would prefer `transact` or any other of your proposed method names over onChange.
Re:React-cursor: a JavaScript implementation of the Cursor c...
by mattdeboard on Tuesday September 23, 2014 @02:23PM
(#8357105)
Oh, huh. Good question. That does seem a little strange.
For example
cursor.refine('b').refine('foo').onChange({ 'bar': 43, baz: 56 })
What is this doing? If onChange isn't transact, what is the react-cursor equivalent?