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 |
Run: ember install ember-custom-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/actionresourceAction(path, options = {})
- will generate request: https://your.api.server/resources/action// 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" }) });
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 })
options
and set default config go to documentation.