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

Promise.isDispatched now exposed as read-only property #72

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/org/osflash/signals/Promise.as
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ package org.osflash.signals
{
private var _isDispatched:Boolean;
private var valueObjects:Array;


/** Whether to ignore any subsequent calls to <code>dispatch()</code>. By default, subsequent calls will throw an error. */
public var ignoreSubsequentDipatches:Boolean = false;

/**
* Creates a Promise instance to dispatch value objects.
* @param valueClasses Any number of class references that enable type checks in dispatch().
Expand Down Expand Up @@ -50,7 +53,10 @@ package org.osflash.signals
{
if (_isDispatched)
{
throw new IllegalOperationError("You cannot dispatch() a Promise more than once");
if (!ignoreSubsequentDipatches)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just use a OnceSignal?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't aware I was submitting this as a pull request! I'm using promises for their retroactive dispatch functionality, and was sometimes getting runtime errors as promises sometimes got dispatched more than once. This just got around that issue.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{
throw new IllegalOperationError("You cannot dispatch() a Promise more than once");
}
}
else
{
Expand Down