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
ApSpinService
create(args) -> 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 |
number
service.countSpin(spinName) -> Count active spins
Param | Type | Description |
---|---|---|
spinName | string | Name of spin |
boolean
service.hasSpin(spinName) -> Detect has a spin or not
Param | Type | Description |
---|---|---|
spinName | string | Name of spin |
Promise
service.spinWhile(spinName, action) -> Show spin while promise pending
Param | Type | Description |
---|---|---|
spinName | string | Name of spin |
action | function | - |
Promise
service.initSpin(spinName) -> Init spin value
Param | Type | Description |
---|---|---|
spinName | string | Name of spin. |
Promise
service.showSpin(spinName) -> Show a spin
Param | Type | Description |
---|---|---|
spinName | string | Name of spin. |
Promise
service.hideSpin(spinName) -> Hide a spin
Param | Type | Description |
---|---|---|
spinName | string | Name of spin. |
License
This software is released under the MIT License.