How to use the ember-invoke-action.invokeAction function in ember-invoke-action

To help you get started, we’ve selected a few ember-invoke-action examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hummingbird-me / hummingbird-client / app / components / users / edit-profile / body / profile-links.js View on Github external
updateProfileLink(link, content) {
      // add or remove from meta record list if this is a new record
      if (get(link, 'isNew')) {
        const action = isEmpty(content) ? 'removeRecord' : 'addRecord';
        invokeAction(this, action, link);
      } else if (get(link, 'isDeleted')) {
        link.rollbackAttributes();
      }
      // update the URL content
      set(link, 'url', content);
    },
github hummingbird-me / hummingbird-client / app / components / stream-feed / items / post / comments.js View on Github external
deletedComment(comment) {
      // if we're on the permalink page then redirect after deletion
      if (get(this, 'comment')) {
        get(this, 'router').transitionTo('posts', get(this, 'post'));
      } else {
        get(this, 'comments').removeObject(comment);
        invokeAction(this, 'countUpdate', get(this, 'post.topLevelCommentsCount') - 1);
      }
    },
github hummingbird-me / hummingbird-client / app / components / stream-feed / items / post / comments.js View on Github external
deletedComment(comment) {
      // if we're on the permalink page then redirect after deletion
      if (get(this, 'comment')) {
        get(this, 'router').transitionTo('posts', [get(this, 'post.id')]);
      } else {
        get(this, 'comments').removeObject(comment);
        invokeAction(this, 'countUpdate', get(this, 'post.topLevelCommentsCount') - 1);
      }
    },
github hummingbird-me / hummingbird-client / app / components / likeable-resource.js View on Github external
destroyLike: task(function* () {
    const like = get(this, 'likes').findBy('user.id', get(this, 'session.account.id'));

    // instant feedback
    set(this, 'isLiked', false);
    invokeAction(this, 'likesCountUpdate', get(this, 'likesCount') - 1);

    // commit and handle error
    yield like.destroyRecord().then(() => {
      get(this, 'likes').removeObject(like);
      const type = get(this, 'resouceLikeType');
      get(this, 'queryCache').invalidateQuery(type, this._getRequestOptions());
    }).catch(() => {
      set(this, 'isLiked', true);
      invokeAction(this, 'likesCountUpdate', get(this, 'likesCount') + 1);
    });
  }).drop(),
github hummingbird-me / hummingbird-client / app / components / stream-feed / items / post / comments.js View on Github external
createComment: task(function* (content, embedUrl = undefined) {
    const data = {
      content,
      embedUrl,
      post: get(this, 'post'),
      user: get(this, 'session.account'),
    };
    const upload = get(this, 'upload');
    if (upload) {
      data.uploads = [upload];
    }
    const comment = get(this, 'store').createRecord('comment', data);
    get(this, 'comments').addObject(comment);

    // update comments count
    invokeAction(this, 'countUpdate', get(this, 'post.topLevelCommentsCount') + 1);
    get(this, 'session.account').incrementProperty('commentsCount');
    yield comment.save().then(() => {
      invokeAction(this, 'trackEngagement', 'comment');
      get(this, 'metrics').trackEvent({ category: 'comment', action: 'create', value: get(this, 'post.id') });
    }).catch((err) => {
      get(this, 'comments').removeObject(comment);
      invokeAction(this, 'countUpdate', get(this, 'post.topLevelCommentsCount') - 1);
      get(this, 'session.account').decrementProperty('commentsCount');
      get(this, 'notify').error(errorMessages(err));
    });
  }).drop(),
github smile-io / ember-cli-stripe / addon / services / stripe.js View on Github external
token() {
        invokeAction(component, 'onToken', ...arguments);

        // Add deprecation for previous `action` callback
        if (!isBlank(component.attrs.action)) {
          deprecate('Using `action` callback is deprecated and will be removed in future versions. Please use `onToken` with a closure action instead',
            false,
            { id: 'ember-cli-stripe.action-callback', until: '1.1.0' }
          );

          invokeAction(component, 'action', ...arguments);
        }
      },
      opened() {
github smile-io / ember-cli-stripe / addon / services / stripe.js View on Github external
token() {
        invokeAction(component, 'onToken', ...arguments);

        // Add deprecation for previous `action` callback
        if (!isBlank(component.attrs.action)) {
          deprecate('Using `action` callback is deprecated and will be removed in future versions. Please use `onToken` with a closure action instead',
            false,
            { id: 'ember-cli-stripe.action-callback', until: '1.1.0' }
          );

          invokeAction(component, 'action', ...arguments);
        }
      },
      opened() {
github hummingbird-me / hummingbird-client / app / components / stream-feed / items / post.js View on Github external
.then(() => {
          // this post is being deleted from its permalink page
          if (get(this, 'group') === undefined) {
            get(this, 'router').transitionTo('dashboard');
          } else {
            // try to find the activity-group that references this post
            let record = get(this, 'store').peekRecord('activity-group', get(this, 'group.id'));
            // might be a new activity-group that doesn't have a set id
            if (record === null || record === undefined) {
              record = get(this, 'store').peekAll('activity-group')
                .find(group => get(group, 'activities').findBy('foreignId', `Post:${get(this, 'post.id')}`));
            }
            invokeAction(this, 'removeGroup', record);
          }
          get(this, 'notify').success('Success! Your post has been deleted.');
        })
        .catch((err) => {
github hummingbird-me / hummingbird-client / app / components / library-dropdown / entry / component.js View on Github external
updateTask: task(function* (status) {
    const entry = get(this, 'entry');
    if (entry === undefined) {
      yield invokeAction(this, 'create', status.key);
    } else if (status.key === REMOVE_KEY) {
      yield invokeAction(this, 'delete');
    } else {
      yield invokeAction(this, 'update', status.key);
    }
  }).drop(),
github hummingbird-me / hummingbird-client / app / components / search-results / group.js View on Github external
transitionTo(item) {
      invokeAction(this, 'close');
      if (typeOf(item) === 'string') {
        get(this, 'router').transitionTo(item);
      } else {
        const type = get(item, 'kind');
        if (type === 'user') {
          get(this, 'router').transitionTo('users.index', get(item, 'slug'));
        } else if (type === 'group') {
          get(this, 'router').transitionTo('groups.group.group-page.index', get(item, 'slug'));
        } else {
          get(this, 'router').transitionTo(`${type}.show`, get(item, 'slug'));
        }
      }
    }
  }

ember-invoke-action

A slightly more idiomatic way to invoke actions in your Ember components

MIT
Latest version published 6 years ago

Package Health Score

36 / 100
Full package analysis

Popular ember-invoke-action functions