@1amageek/flow 中文文档教程
flow.ts
Flow 支持结构化脚本的编码。
Installation
yarn add @1amageek/flow
Usage
class Item implements Flow.Dependency {
status?: string
}
var item: Item = new Item()
const step0: Flow.Step<Item> = new Flow.Step((item) => {
// Do something
return item
})
const step1: Flow.Step<Item> = new Flow.Step( async (item) => {
try {
return await asyncFunction()
} catch(err) {
// Error handling
throw(err)
}
})
const step2: Flow.Step<Item> = new Flow.Step((item) => {
// Do something
return item
})
const flow: Flow.Line<Item> = new Flow.Line([step0, step1, step2])
try {
await flow.run(item)
} catch(error) {
// Error handling
}
flow.ts
Flow enables coding of structured scripts.
Installation
yarn add @1amageek/flow
Usage
class Item implements Flow.Dependency {
status?: string
}
var item: Item = new Item()
const step0: Flow.Step<Item> = new Flow.Step((item) => {
// Do something
return item
})
const step1: Flow.Step<Item> = new Flow.Step( async (item) => {
try {
return await asyncFunction()
} catch(err) {
// Error handling
throw(err)
}
})
const step2: Flow.Step<Item> = new Flow.Step((item) => {
// Do something
return item
})
const flow: Flow.Line<Item> = new Flow.Line([step0, step1, step2])
try {
await flow.run(item)
} catch(error) {
// Error handling
}