You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 5, 2023. It is now read-only.
Often we use AS3 EventDispatchers with custom events. Developers add listeners to dispatchers for two (2) scenarios:
Listeners to respond to repeated occurrence of events (e.g. mouseDown, click, etc). or
Once-only listeners to respond to a single occurrence of an event (e.g. Authentication, etc)
In the case of adding listeners for once-only actions (2 above), having the ability to easily use Promise(s) instead of adding and removing listeners can dramatically simplify developer code:
Consider the sample scenario below:
function loginUser( userName:String, password:String ):Promise
{
var authenticator : Authenticator = new Authenticator;
authenticator.loginUser( userName, password );
return Promise.when( new EventIntercepter (
authenticator,
AuthenticationEvent.AUTHENTICATED, 'session',
AuthenticationEvent.NOT_ALLOWED, 'details'
));
}
loginUser(
'ThomasB',
"superSecretPassword"
)
.then(
function onLoginOK( session:Object ):void {
// Save the session information and continue login process
},
function onLoginFailed( fault:Object ):void {
// Report the login failure and request another attempt
}
);
If this seems valuable, please review the EventIntercepter and DispatcherAdapter classes in
Often we use AS3 EventDispatchers with custom events. Developers add listeners to dispatchers for two (2) scenarios:
In the case of adding listeners for once-only actions (2 above), having the ability to easily use Promise(s) instead of adding and removing listeners can dramatically simplify developer code:
Consider the sample scenario below:
If this seems valuable, please review the EventIntercepter and DispatcherAdapter classes in
https://github.com/ThomasBurleson/promise-as3/commit/8e7bd76b88afd666df37572c66e077d08d7fe3fe
The text was updated successfully, but these errors were encountered: