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

Add names for action and linkTo functions #321

Merged
merged 1 commit into from
Jul 18, 2016
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
7 changes: 3 additions & 4 deletions dist/client/preview/client_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ var ClientApi = function () {
value: function action(name) {
var pageBus = this._pageBus;

return function () {
return function action() {
for (var _len2 = arguments.length, _args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
_args[_key2] = arguments[_key2];
}
Expand All @@ -133,17 +133,16 @@ var ClientApi = function () {

var id = _uuid2.default.v4();
var data = { name: name, args: args };
var action = { data: data, id: id };

pageBus.emit('addAction', { action: action });
pageBus.emit('addAction', { action: { data: data, id: id } });
};
}
}, {
key: 'linkTo',
value: function linkTo(kind, story) {
var pageBus = this._pageBus;

return function () {
return function linkTo() {
var resolvedKind = typeof kind === 'function' ? kind.apply(undefined, arguments) : kind;
var resolvedStory = typeof story === 'function' ? story.apply(undefined, arguments) : story;

Expand Down
7 changes: 3 additions & 4 deletions src/client/preview/client_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export default class ClientApi {
action(name) {
const pageBus = this._pageBus;

return function (..._args) {
return function action(..._args) {
let args = Array.from(_args);

// Remove events from the args. Otherwise, it creates a huge JSON string.
Expand All @@ -88,16 +88,15 @@ export default class ClientApi {

const id = UUID.v4();
const data = { name, args };
const action = { data, id };

pageBus.emit('addAction', { action });
pageBus.emit('addAction', { action: { data, id } });
};
}

linkTo(kind, story) {
const pageBus = this._pageBus;

return function (...args) {
return function linkTo(...args) {
const resolvedKind = typeof kind === 'function' ? kind(...args) : kind;
const resolvedStory = typeof story === 'function' ? story(...args) : story;

Expand Down