Comparing version 4.1.2 to 4.1.3
@@ -122,15 +122,8 @@ import { render, directive } from 'https://unpkg.com/lit-html@^1.0.0/lit-html.js'; | ||
teardown() { | ||
let effects = this[effectsSymbol]; | ||
if(effects) { | ||
for(let effect of effects) { | ||
effect.teardown(); | ||
let hooks = this[hookSymbol]; | ||
hooks.forEach((hook) => { | ||
if (typeof hook.teardown === 'function') { | ||
hook.teardown(); | ||
} | ||
} | ||
let contexts = this[contextSymbol]; | ||
if(contexts) { | ||
for(let context of contexts) { | ||
context.unsubscribe(); | ||
} | ||
} | ||
}); | ||
} | ||
@@ -437,3 +430,3 @@ } | ||
unsubscribe() { | ||
teardown() { | ||
if (this._unsubscribe) { | ||
@@ -501,2 +494,2 @@ this._unsubscribe(); | ||
export { component, useCallback, useEffect, useState, useReducer, useMemo, withHooks, withHooks as virtual, useContext, createContext }; | ||
export { component, useCallback, useEffect, useState, useReducer, useMemo, withHooks, withHooks as virtual, useContext, createContext, hook, Hook }; |
21
index.js
@@ -122,15 +122,8 @@ import { render, directive } from 'lit-html'; | ||
teardown() { | ||
let effects = this[effectsSymbol]; | ||
if(effects) { | ||
for(let effect of effects) { | ||
effect.teardown(); | ||
let hooks = this[hookSymbol]; | ||
hooks.forEach((hook) => { | ||
if (typeof hook.teardown === 'function') { | ||
hook.teardown(); | ||
} | ||
} | ||
let contexts = this[contextSymbol]; | ||
if(contexts) { | ||
for(let context of contexts) { | ||
context.unsubscribe(); | ||
} | ||
} | ||
}); | ||
} | ||
@@ -437,3 +430,3 @@ } | ||
unsubscribe() { | ||
teardown() { | ||
if (this._unsubscribe) { | ||
@@ -501,2 +494,2 @@ this._unsubscribe(); | ||
export { component, useCallback, useEffect, useState, useReducer, useMemo, withHooks, withHooks as virtual, useContext, createContext }; | ||
export { component, useCallback, useEffect, useState, useReducer, useMemo, withHooks, withHooks as virtual, useContext, createContext, hook, Hook }; |
{ | ||
"name": "haunted", | ||
"version": "4.1.2", | ||
"version": "4.1.3", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -372,2 +372,22 @@ # Haunted 🦇 🎃 | ||
#### Write Your Own Hook | ||
Most functionality can be achieved with the provided hooks above, but you can also create your own hooks for custom functionality. | ||
```html | ||
import { hook, Hook } from 'haunted'; | ||
const useMyHook = hook(class extends Hook { | ||
constructor(id, el) { | ||
super(id, el); | ||
... | ||
} | ||
update() { ... } | ||
teardown() { ... } | ||
}); | ||
``` | ||
### Function Signatures | ||
@@ -374,0 +394,0 @@ |
25
web.js
@@ -1,3 +0,3 @@ | ||
import { render, directive } from '../node_modules/lit-html/lit-html.js'; | ||
export { html, render } from '../node_modules/lit-html/lit-html.js'; | ||
import { render, directive } from '../lit-html/lit-html.js'; | ||
export { html, render } from '../lit-html/lit-html.js'; | ||
@@ -122,15 +122,8 @@ const symbolFor = typeof Symbol === 'function' ? Symbol.for : str => str; | ||
teardown() { | ||
let effects = this[effectsSymbol]; | ||
if(effects) { | ||
for(let effect of effects) { | ||
effect.teardown(); | ||
let hooks = this[hookSymbol]; | ||
hooks.forEach((hook) => { | ||
if (typeof hook.teardown === 'function') { | ||
hook.teardown(); | ||
} | ||
} | ||
let contexts = this[contextSymbol]; | ||
if(contexts) { | ||
for(let context of contexts) { | ||
context.unsubscribe(); | ||
} | ||
} | ||
}); | ||
} | ||
@@ -437,3 +430,3 @@ } | ||
unsubscribe() { | ||
teardown() { | ||
if (this._unsubscribe) { | ||
@@ -501,2 +494,2 @@ this._unsubscribe(); | ||
export { component, useCallback, useEffect, useState, useReducer, useMemo, withHooks, withHooks as virtual, useContext, createContext }; | ||
export { component, useCallback, useEffect, useState, useReducer, useMemo, withHooks, withHooks as virtual, useContext, createContext, hook, Hook }; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
405
44233
1206