Railway oriented programming in Ember. To install:
ember install ember-pipeline
ember-pipeline
allows you to compose a pipeline of (promise aware) methods on an object using "railway oriented programming". That is, if any of the methods in the pipeline returns a CANCEL
token, the entire pipeline exits and can be optionally handled by another method. If the host Ember.Object
is destroyed, the pipeline is aborted as well.
For example:
import Ember from 'ember';
import { pipeline, step, CANCEL } from 'ember-pipeline';
const { computed, get } = Ember;
export default Component.extend({
fetchStoreLocations: computed(function() {
return pipeline(this, [
step('requestGeolocation'),
step('fetchStoresInProximity'),
step('sortStoresByDistance'),
step('alwaysCancels')
]).onCancel((cancellation) => this.handleCancel(cancellation));
}),
requestGeolocation() { /* ... */ },
fetchStoresInProximity() { /* ... */ },
sortStoresByDistance() { /* ... */ },
alwaysCancels() {
return CANCEL();
},
handleCancel(cancellation) {
switch (cancellation.fnName) {
case 'requestGeolocation':
// show error message saying you didn't allow us to use geo api
break;
case 'fetchStoresInProximity':
// no stores around you, sorry!
break;
case 'sortStoresByDistance':
// we used bubble sort
break;
default:
// no cancel handler
console.log(`last value: ${cancellation.result}, reason: ${cancellation.reason}`);
break;
}
}),
actions: {
fetchStoreLocations(...args) {
return get(this, 'fetchStoreLocations').perform(...args);
}
}
});
First, create a pipeline using pipeline
and step
. You can also define a cancel handler:
return pipeline(this, [
step('step1'),
step('step2'),
step('step3')
]).onCancel((cancellation) => this.handleCancel(cancellation));
If using inside of an Ember.Object
, you could make this a computed property:
export default Component.extend({
myPipeline: computed(function() {
return pipeline(this, [
step('step1'),
step('step2'),
step('step3')
]).onCancel((cancellation) => this.handleCancel(cancellation));
})
});
step
receives either a method name as a string, or a function:
[step('step1'), step(x => x * x)];
In a step
function, return CANCEL()
to abort the pipeline:
{
step1() {
return CANCEL('optional reason, can be any type');
}
}
Then, to run the pipeline, get the reference to it and perform
it:
get(this, 'myPipeline').perform(...args);
pipelineInstance.perform(...args);
You can compose new pipelines at runtime. For example:
export default Component.extend({
makePipeline(steps) {
return pipeline(this, steps)
.onCancel((cancellation) => this.handleCancel(cancellation));
},
// ...
actions: {
normal(...args) {
return this.makePipeline([step('step1'), step('step2')]).perform(...args);
},
reverse(...args) {
return this.makePipeline([step('step2'), step('step1')]).perform(...args);
}
}
});
After a pipeline has been performed, you can get derived state:
get(this, 'myPipeline').perform(1, 2, 3);
get(this, 'myPipeline.successfulSteps.length'); // 2
get(this, 'myPipeline.cancelledSteps.length'); // 1
get(this, 'myPipeline.successfulSteps'); // array of successful Steps
get(this, 'myPipeline.cancelledSteps'); // array of cancelled Steps
Because features are still in flux, detailed API docs are coming soon!
ember-concurrency
tasksgit clone <repository-url>
this repositorycd ember-pipeline
npm install
bower install
ember serve
npm test
(Runs ember try:each
to test your addon against multiple Ember versions)ember test
ember test --server
ember build
For more information on using ember-cli, visit https://ember-cli.com/.
ref: http://www.javascriptturnsmeon.com/javascript-build-process-rake-pipeline-with-minispade/ 项目地址: https://github.com/AmongOthers/rakepDemo 构建web app的时候,将不同的功能分模块,并在物理上分开写在各自的文件里,有利于理解。而web app有一个
Ember检查器是一个浏览器插件,用于调试Ember应用程序。 灰烬检查员包括以下主题 - S.No. 灰烬检查员方式和描述 1 安装Inspector 您可以安装Ember检查器来调试您的应用程序。 2 Object Inspector Ember检查器允许与Ember对象进行交互。 3 The View Tree 视图树提供应用程序的当前状态。 4 检查路由,数据选项卡和库信息 您可以看到检查
英文原文: http://emberjs.com/guides/getting-ember/index/ Ember构建 Ember的发布管理团队针对Ember和Ember Data维护了不同的发布方法。 频道 最新的Ember和Ember Data的 Release,Beta 和 Canary 构建可以在这里找到。每一个频道都提供了一个开发版、最小化版和生产版。更多关于不同频道的信息可以查看博客
ember-emojione ember-emojione is your emoji solution for Ember, based on the EmojiOne project. EmojiOne version 2 is used, which is free to use for everyone (CC BY-SA 4.0), you're only required to giv
Ember 3D Ember 3D is an Ember addon for using Three.js - an easy to use, lightweight, javascript 3D library. It is designed to: Prescribe a solid file structure to Three.js code using ES6 modules. Ena
Ember Table An addon to support large data set and a number of features around table. Ember Table canhandle over 100,000 rows without any rendering or performance issues. Ember Table 3.x supports: Emb
vscode-ember This is the VSCode extension to use the Ember Language Server. Features All features currently only work in Ember-CLI apps that use classic structure and are a rough first draft with a lo
ember-headlessui This is a work-in-progress implementation of: https://github.com/tailwindlabs/headlessui A set of completely unstyled, fully accessible UI components for Ember.js, designed to integra
Ember Popper An Ember-centric wrapper around Popper.js. Currently an alpha in active development. See the dummy app for examples Compatibility Ember.js v3.12 or above Ember CLI v2.13 or above Node.js