Live Examples

Custom Actions Requests Results
Publish post

Waiting

posts/1/publish

Call custom action
Burn all bridges

Waiting

bridges/burn

Call custom action
Generate Profile

Waiting

users/1/generate

Call custom action

Getting started

How to start with ember-custom-actions


1. Instalation

Run: ember install ember-custom-actions

2. Setup actions

Define proper actions in your models by choosing one of the following methods:

  • modelAction(path, options = {}) - will generate request: https://your.api.server/resources/1/action
  • resourceAction(path, options = {}) - will generate request: https://your.api.server/resources/action

Example implementation

  // app/models/post.js

  import Model from "ember-data/model";
  import { modelAction, resourceAction } from "ember-custom-actions";

  export default Model.extend({
    publish: modelAction("publish", { promiseType: "object" }),
    search: resourceAction("search", { type: "GET", normalizeOperation: "dasherize" })
  });
    

3. Usage example

You can call custom action by resolving a promise on model object, eg:


  // app/models/post.js

  this.get("post").publish({ publisherId: 1 }).then((response) => {
    // you can make some operations on your server"s response data
  })
    

4. Configuration

To check possible options and set default config go to documentation.

Documentation & Configuration

An advanced way to get to know ember-custom-actions better

dcumentatin