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

Make sure ActionCreators will work with es6 arrow syntax. Fixes #83 #84

Merged
merged 6 commits into from
Jan 26, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
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
15 changes: 11 additions & 4 deletions dist/marty.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ function ActionCreators(options) {
}

module.exports = ActionCreators;

},{"../constants/actions":1,"./actionPayload":10,"./dispatcher":14,"./utils/serializeError":25,"./utils/uuid":26,"underscore":39}],10:[function(require,module,exports){
var _ = require('underscore');
var uuid = require('./utils/uuid');
Expand Down Expand Up @@ -1213,16 +1214,22 @@ function Store(options) {
});

function validateOptions(options) {
var errors = [];
var missingFunctions = [];

_.each(REQUIRED_FUNCTIONS, function (functionName) {
if (!_.has(options, functionName)) {
errors.push('You must implement ' + functionName);
missingFunctions.push(functionName);
}
});

if (errors.length) {
throw new Error(errors.join('. '));
if (missingFunctions.length) {
var error = 'You must implement ' + missingFunctions.join(',');

if (options.displayName) {
error += ' in ' + options.displayName;
}

throw new Error(error);
}
}

Expand Down
6 changes: 3 additions & 3 deletions dist/marty.min.js

Large diffs are not rendered by default.

Binary file modified dist/marty.min.js.gz
Binary file not shown.
6 changes: 5 additions & 1 deletion docs/_api/action-creators/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ var UserActionCreators = Marty.createActionCreators({
});
{% endhighlight %}

<div class="alert alert-warning" role="alert">
<strong>Warning!</strong> Please avoid using es6 arrow syntax for your callbacks since they are bound to the current context.
</div>

<h2 id="displayName">displayName</h2>

An (optional) display name for the action creator. Used for richer debugging.
Expand All @@ -24,4 +28,4 @@ An (optional) display name for the action creator. Used for richer debugging.

Dispatches an action payload. Any [action handlers](/api/stores/index.html#handleAction) will be invoked with the given action handlers.

Returns <code>Action</code>. You can rollback an action by calling <code>action.rollback()</code>.
Returns <code>Action</code>. You can rollback an action by calling <code>action.rollback()</code>.
6 changes: 5 additions & 1 deletion docs/_guides/action-creators/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ Dispatcher.register(function (action) {
UserActionCreators.updateEmail(123, "foo@bar.com");
{% endhighlight %}

<div class="alert alert-warning" role="alert">
<strong>Warning!</strong> Please avoid using es6 arrow syntax for your callbacks since they are bound to the current context.
</div>

You often want to know if an action is starting, finished or has failed. To help here Marty actually emits a number of other actions:

* When an action is about to start
Expand All @@ -54,4 +58,4 @@ You often want to know if an action is starting, finished or has failed. To help
* ``ACTION_FAILED`` (see ``require('marty/constants/actions')``)
* ``{Action Type}_FAILED`` (e.g. ``UPDATE_EMAIL_FAILED``)

If the action creator returns a promise then Marty will wait for the promise to resolve or be rejected before dispatching done/failed actions.
If the action creator returns a promise then Marty will wait for the promise to resolve or be rejected before dispatching done/failed actions.
2 changes: 1 addition & 1 deletion lib/actionCreators.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,4 +168,4 @@ function ActionCreators(options) {
}
}

module.exports = ActionCreators;
module.exports = ActionCreators;