nev*_*fox 5 promise coffeescript ember.js rsvp.js
我试图在Controller动作的Promise处理程序中使用_super,但它不起作用,因为它似乎失去了正确的函数链.
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()
Run Code Online (Sandbox Code Playgroud)
我想恢复到Mixin的默认行为,else但我需要user在执行条件语句之前异步解析.我试过了:
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()
Run Code Online (Sandbox Code Playgroud)
和
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(@)()
Run Code Online (Sandbox Code Playgroud)
两者都不起作用.
这个答案声称这应该适用于1.5.0,但我使用的是1.7.0-beta.5而且它没有用.有没有办法让这个工作,即使在接近这个方面有所不同?
Ember 目前不支持_super异步调用。在该示例中,我实际上并没有_super异步调用,它仍然是同步的。
| 归档时间: |
|
| 查看次数: |
512 次 |
| 最近记录: |