HotDrink / hotdrink

JavaScript MVVM library with support for multi-way dependencies and generic, rich UI behaviors.
http://hotdrink.github.io/hotdrink/
58 stars 9 forks source link

Direct mutation of outputs in methods #33

Closed thejohnfreeman closed 12 years ago

thejohnfreeman commented 12 years ago

Methods should be able to return new values for outputs or mutate them directly. This feature should come with a change to the pubsub system to better support event drafts.

gfoust commented 12 years ago

If the method mutates the output directly, what would be the return value of the method? I'd like to suggest that it still return a value that is assigned to the output variable—or at least have the option of doing that. So if I indicate that I'm modifying the output variable, I could still return a completely different value for the output—not necessarily just a modified version of what's already there. That way it would be easier to write methods that may do one or the other.

thejohnfreeman commented 12 years ago

I'm planning to let methods do one or the other, not both. If the method returns nothing or undefined (which are equivalent), then the outputs are checked for changes. If the method returns anything else, it is assigned to the output(s).

thejohnfreeman commented 12 years ago

My patch is incomplete. Do not use direct mutation of outputs yet.