Call Ember _super method from Promise handler

I am trying to use _super in the Promise handler inside the Controller action, but it does not work because it seems to lose the correct chain of functions.

ApplicationRoute = Ember.Route.extend SimpleAuth.ApplicationRouteMixin, actions: sessionAuthenticationSucceeded: -> @get("session.user").then (user) => if @get("session.isTemporaryPassword") or not user.get "lastLogin" @transitionTo "temp-password" else @_super() 

I want to return to Mixin's default behavior in else , but I need to allow user asynchronously before I can make a conditional statement. I tried:

 ApplicationRoute = Ember.Route.extend SimpleAuth.ApplicationRouteMixin, actions: sessionAuthenticationSucceeded: -> _super = @_super @get("session.user").then (user) => if @get("session.isTemporaryPassword") or not user.get "lastLogin" @transitionTo "temp-password" else _super() 

and

 ApplicationRoute = Ember.Route.extend SimpleAuth.ApplicationRouteMixin, actions: sessionAuthenticationSucceeded: -> @get("session.user").then (user) => if @get("session.isTemporaryPassword") or not user.get "lastLogin" @transitionTo "temp-password" else @_super.bind(@)() 

Nothing works.

This answer claimed that this should work with 1.5.0, but I am using 1.7.0-beta.5 and it does not go. Is there a way to make this work, even in terms of approaching it differently?

+5
source share
2 answers

Ember does not currently support the asynchronous call to _super . In this example, I do not actually call _super asynchronously, but it is synchronous.

http://emberjs.com/blog/2014/03/30/ember-1-5-0-and-ember-1-6-beta-released.html#toc_ever-present-_super-breaking-bugfix

+3
source

To continue the bubble, you need to call this.target.send() with the action name.

see below: How can I trigger an Ember action inside a callback function?

Something like this should work:

 ApplicationRoute = Ember.Route.extend SimpleAuth.ApplicationRouteMixin, actions: sessionAuthenticationSucceeded: -> @get("session.user").then (user) => if @get("session.isTemporaryPassword") or not user.get "lastLogin" @transitionTo "temp-password" else @target.send('sessionAuthenticationSucceeded') 
0
source

Source: https://habr.com/ru/post/1202823/


All Articles