项目作者: tarmann

项目描述 :
Ember model, store and custom methods as task actions.
高级语言: JavaScript
项目地址: git://github.com/tarmann/ember-actions-service.git
创建时间: 2017-10-13T14:26:01Z
项目社区:https://github.com/tarmann/ember-actions-service

开源协议:MIT License

下载


ember-actions-service

ember-actions-service is an Ember Addon to wrap common store and model methods with ember-concurrency tasks and making them available as a service.

Build Status
Maintainability
Test Coverage
Ember Observer Score

Usage

Blueprint:

  1. ember g actions-service user

Route

  1. import Route from '@ember/routing/route';
  2. import { actionsMixin } from 'ember-actions-service';
  3. export default Route.extend(actionsMixin('user'), {});

Template using route-actions

  1. {{user-editor saveAction=(route-action "userActions" user "save")}}

Actions

The following actions perform a ember-concurrency task and return a task instance.

  • find
  • findAll
  • create
  • save
  • delete
  • unload
  • rollback

Custom Actions

To implement a new action just include a new task into the service generated following the format bellow:

  1. doSomethingTask: task(function * (store, callback, model){
  2. updatedModel = yield doSomething(model);
  3. return { callback, model: updatedModel };
  4. })

Compatibility

  • Ember.js v2.18 or above
  • Ember CLI v2.13 or above

Installation

  1. ember install ember-actions-service

License

This project is licensed under the MIT License.