RiotJS - How to pass events between subtags using Observable pattern?

前端 未结 5 596
暗喜
暗喜 2021-01-01 02:15

Im not really sure if Im understanding correctly the way observables work and how to get references from mounted tags. I have a component. Within this comp

5条回答
  •  长情又很酷
    2021-01-01 02:42

    Maybe overkill but simple. let riot self observable

    riot.observable(riot);
    

    So you can use

    riot.on('someEvent', () => {
      // doing something
    });
    

    in a tag, and

    riot.trigger('someEvent');
    

    in another.

    It's not good to use global variable, but use an already exists one maybe acceptable.

提交回复
热议问题