소스 검색

docs(Spruce.off)

Ryan Chandler 5 년 전
부모
커밋
8494ab1ab9
1개의 변경된 파일16개의 추가작업 그리고 0개의 파일을 삭제
  1. 16 0
      README.md

+ 16 - 0
README.md

@@ -196,6 +196,22 @@ Spruce.on('init', ({ store }) => {
 })
 ```
 
+* `Spruce.off(eventName, callback)` - this can be used to unhook or de-register an event listener.
+
+```js
+var callback = () => {}
+
+Spruce.off('init', callback)
+```
+
+You can also unhook a listener using the function returned by `Spruce.on()`. This is especially useful for anonymous function callbacks.
+
+```js
+var off = Spruce.on('event', () => {})
+
+off()
+```
+
 * `Spruce.emit(eventName, data = {})` - this can be used to emit an event. The first argument should be the name of the event, the second should be an object containing data. This will be merged in with the core data, which consists of a `store` property. When emitting an event, a browser event will also be dispatched with a `spruce:` prefix.
 
 ```js