npm.io
1.0.2 • Published 10 years ago

sync-mixin

Licence
MIT
Version
1.0.2
Deps
1
Vulns
0
Weekly
0

sync-mixin

NPM Package Build Status Coverage Status js-standard-style Dependency status

Installation

npm install sync-mixin

API

_getSyncCount()

return: number

_setSyncCount()
  • number value
_syncEnter()
_syncExit()
_withSync()
  • function fn

return: Promise

_syncExitAll()
isSyncing()

Examples

import { mixin } from 'core-decorators'
import SyncMixin from 'sync-mixin'

@mixin(SyncMixin)
class Process {
  run () {
    return this._withSync(() => {
      // some code that require time for execution
    })
  }
}

let process = new Process()
process.on('syncStart', () => console.log('Syncronization started!'))
process.on('syncStop', () => console.log('Syncronization finished!'))
setInterval(::process.run, 60 * 1000)

License

This software is licensed under the MIT License.

Keywords