3.0.1 • Published 8 years ago
apeman-service-spin v3.0.1
apeman-service-spin
Service for spin
Installation
$ npm install apeman-service-spin --save
Usage
#!/usr/bin/env node
'use strict'
const { ApSpinService } = require('apeman-service-spin')
const { createStore } = require('redux')
const { reducer } = require('apeman-service-base')
const co = require('co')
co(function * () {
let store = createStore(reducer)
let service = new ApSpinService(store)
yield service.initSpin('ROOT_SPIN')
yield service.spinWhile('ROOT_SPIN', () => {
return Promise.resolve(true)
})
let spinning = service.hasSpin('ROOT_SPIN')
console.log(spinning)
}).catch((err) => console.error(err))
API
apeman-service-spin@3.0.1
Service for spin
- Functions
- ApSpinService Class
Functions
create(args) -> ApSpinService
Create the service instance
Param | Type | Description |
---|---|---|
args | * |
ApSpinService Class
Service to handle spin.
new ApSpinService(store, options)
Constructor of ApSpinService class
Param | Type | Description |
---|---|---|
store | Object | Redux store |
options | Object | Optional settings |
service.countSpin(spinName) -> number
Count active spins
Param | Type | Description |
---|---|---|
spinName | string | Name of spin |
service.hasSpin(spinName) -> boolean
Detect has a spin or not
Param | Type | Description |
---|---|---|
spinName | string | Name of spin |
service.spinWhile(spinName, action) -> Promise
Show spin while promise pending
Param | Type | Description |
---|---|---|
spinName | string | Name of spin |
action | function | - |
service.initSpin(spinName) -> Promise
Init spin value
Param | Type | Description |
---|---|---|
spinName | string | Name of spin. |
service.showSpin(spinName) -> Promise
Show a spin
Param | Type | Description |
---|---|---|
spinName | string | Name of spin. |
service.hideSpin(spinName) -> Promise
Hide a spin
Param | Type | Description |
---|---|---|
spinName | string | Name of spin. |
License
This software is released under the MIT License.