https://www.npmjs.com/package/pauseablenpm
Pauseable allows you to pause event emitters, timeouts, and intervals. It can group multiple of these pauseable objects and pause entire groups.app
The function
and ms
arguments are interchangeable. Use whichever way you prefer!dom
Javascript is event based by nature. When developing large scale applications that are completely event based, it becomes complicated to pause the streaming of events, because Javascript never "sleeps". It becomes even more complicated to pause timeouts and intervals, having to keep track of when they were paused so they can be resumed with the correct time again.curl
That's where this module comes in. Pauseable helps manage pausing and resuming your application or part of it. It works with EventEmitter
, with setInterval
and setTimeout
.ui
用途:this
一、 頁面遊戲, 例如花朵和殭屍, 可使用魔法將殭屍定住一段時間, 時間到後殭屍繼續行動。url
二、 XX功能關閉, 對於XX功能是由事件監聽驅動的, 可使用這個功能臨時關閉掉, 須要的時候再打開。spa