What's the best way to scope an event on two similar Riot components using two different RiotControl stores?
Right now, no matter what button is pressed, the action is applied on both tags, since the control stores are global. I'm trying to figure out what's the best way to scope one tag per store.
My actual use case will have multiple nested tags, so passing the Store around may not be ideal.
I've set up an example at: https://jsfiddle.net/Lsc3znng/
My Tag:
<script type="riot/tag">
<play>
<button onclick={ toggle }>{opts.name}</button>
<p name="status">unclicked</p>
var self = this
RiotControl.on('play', function() {
self.status.innerText = "clicked"
})
toggle(e) {
RiotControl.trigger('play_toggle')
}
</play>
</script>
My Store:
function ButtonControlStore() {
riot.observable(this)
var self = this
self.on('play_toggle', function() {
self.trigger('play')
})
}
var controlStoreOne = new ButtonControlStore()
var controlStoreTwo = new ButtonControlStore()
RiotControl.addStore(controlStoreOne)
RiotControl.addStore(controlStoreTwo)