Question about binding

8 views
Skip to first unread message

murrayh...@gmail.com

unread,
Jul 5, 2015, 7:26:52 AM7/5/15
to gl...@googlegroups.com
Hi.

On a viewModel with a property of searchText (bound to a textfield on the view), when the user enters text the reactor fires. All good.

searchText: '',

when_the_user_enters_search_text_then_filter_grid: {
on: ['searchTextChanged'],
action: function() {
console.log('text changed in reactor') // Reactor works
}
},

Now. Given that watching for changing properties intrinsic in GluJS, why cant I just do this instead:

searchTextChanged: function() {
console.log('text changed in searchTextChanged') // Doesnt work
}

Or maybe I can in some other syntax and I just cant see the wood for the trees?

Thanks,
Murray

murrayh...@gmail.com

unread,
Jul 5, 2015, 7:33:27 AM7/5/15
to gl...@googlegroups.com, murrayh...@gmail.com
Oh. Ok. You can.

onSearchTextChanged : function(){
console.log('text changed in onSearchTextChanged', arguments)
}

Is there a reason NOT to do this since it is simpler than the reactor? Yes, the reactor has a useful name but that could be in a comment anyway.

Thanks,
Murray

Josh VanderLinden

unread,
Jul 5, 2015, 11:36:58 AM7/5/15
to gl...@googlegroups.com

Not doing it as "onSearchTextChanged" allows you to have multiple reactors that handle the same event. I often do this for more single-purpose functions that are easier to debug than tossing everything into a single "onFooChanged" function.

Murray Hopkins

unread,
Jul 5, 2015, 1:19:27 PM7/5/15
to gl...@googlegroups.com

Thanks Josh. Got it!

Murray

On 6 Jul 2015 1:36 am, "Josh VanderLinden" <wheati...@gmail.com> wrote:

Not doing it as "onSearchTextChanged" allows you to have multiple reactors that handle the same event. I often do this for more single-purpose functions that are easier to debug than tossing everything into a single "onFooChanged" function.

--
You received this message because you are subscribed to a topic in the Google Groups "GluJS" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/glujs/QmlldRU4Qe8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to glujs+un...@googlegroups.com.
To post to this group, send email to gl...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/glujs/CAPrOEMquP9Tq_LhNTE-HUjL1at4CFE2oOBenRf3E8M-QWR63fQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages