Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RiotControl Gotchas #34

Open
ghstahl opened this issue Oct 5, 2016 · 1 comment
Open

RiotControl Gotchas #34

ghstahl opened this issue Oct 5, 2016 · 1 comment

Comments

@ghstahl
Copy link

ghstahl commented Oct 5, 2016

Can we start a Gotchas readme?

RiotControl .on and .off need to match in your riotjs tags.
Don't forget to unregister your RiotControl event handlers if you are registering them in your mount.

<myTag>
<script>
        var self = this;
         self.onAspNetRolesChanged = (data) =>{
            console.log('aspnet_roles_changed',data)
         }
         self.onAspNetUserChanged= (data) =>{
            console.log('aspnet_user_changed',data)
         }
        self.on('before-mount',function(){
            console.log('on before-mount: aspnet-user-detail');
            RiotControl.on('aspnet_roles_changed', self.onAspNetRolesChanged);
            RiotControl.on('aspnet_user_changed', self.onAspNetUserChanged);
        });
        self.on('unmount', function() {
            RiotControl.off('aspnet_roles_changed', self.onAspNetRolesChanged);
            RiotControl.off('aspnet_user_changed', self.onAspNetUserChanged);
        })
</script>
</myTag>

I was wondering why my self.onAspNetUserChanged kept stacking. On every subsequent mount, I was adding a new event handler.

@tooolbox
Copy link

tooolbox commented Dec 4, 2016

Goes along with #18

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants