mikeric / rivets

Lightweight and powerful data binding.
http://rivetsjs.com
MIT License
3.23k stars 310 forks source link

Get Callback when component args change #738

Open GtrPksRnt4eatin opened 2 years ago

GtrPksRnt4eatin commented 2 years ago

Hello, not really an issue but more a question/feature request. Is there any way that i can trigger a callback function on a rivets components viewModel anytime the arguments to the component change? I have a plugin that needs some manual setup/configuration within the view. I would like to trigger the functions that do this from within the component every time the arguments change. I was thinking something along the lines of the following:

rivets.components['session-chooser'] = { template: function() { return SessionChooser.prototype.HTML; }, initialize: function(el,attr) { let viewModel = new SessionChooser(el,attr);
this.observers.event.callback <- point this at a function on the viewModel somehow or add another observer to do so.. return viewModel; } }