Skip to content

Commit

Permalink
feat: add Watcher.omitWarningForForgetWatch
Browse files Browse the repository at this point in the history
  • Loading branch information
Jack-Works committed Aug 6, 2019
1 parent ead55f0 commit 8c9589f
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions api-documents/kit.watcher.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export declare abstract class Watcher<T, Before extends Element, After extends E
| [enableBatchMode()](./kit.watcher.enablebatchmode.md) | | Dismiss the warning that let you enable single mode but the warning is false positive. |
| [enableSingleMode()](./kit.watcher.enablesinglemode.md) | | Enable single mode. |
| [getVirtualNodeByKey(key)](./kit.watcher.getvirtualnodebykey.md) | | Get virtual node by key. Virtual node will be unavailable if it is deleted |
| [omitWarningForForgetWatch()](./kit.watcher.omitwarningforforgetwatch.md) | | If you're expecting Watcher may not be called, call this function, this will omit the warning. |
| [omitWarningForRepeatedKeys()](./kit.watcher.omitwarningforrepeatedkeys.md) | | If you're expecting repeating keys, call this function, this will omit the warning. |
| [removeListener(event, fn)](./kit.watcher.removelistener.md) | | |
| [removeListener(event, fn)](./kit.watcher.removelistener_1.md) | | |
Expand Down
17 changes: 17 additions & 0 deletions api-documents/kit.watcher.omitwarningforforgetwatch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@holoflows/kit](./kit.md) &gt; [Watcher](./kit.watcher.md) &gt; [omitWarningForForgetWatch](./kit.watcher.omitwarningforforgetwatch.md)

## Watcher.omitWarningForForgetWatch() method

If you're expecting Watcher may not be called, call this function, this will omit the warning.

<b>Signature:</b>

```typescript
omitWarningForForgetWatch(): this;
```
<b>Returns:</b>

`this`

1 change: 1 addition & 0 deletions doc/holoflows-kit.api.report.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ export abstract class Watcher<T, Before extends Element, After extends Element,
protected lastVirtualNodesMap: Map<unknown, DomProxy<any, Before, After>>;
protected readonly liveSelector: LiveSelector<T, SingleMode>;
protected mapNodeToKey: (node: T, index: number, arr: readonly T[]) => unknown;
omitWarningForForgetWatch(): this;
omitWarningForRepeatedKeys(): this;
// (undocumented)
removeListener(event: 'onIteration', fn: EventCallback<OnIterationEvent<T>>): this;
Expand Down
7 changes: 7 additions & 0 deletions src/DOM/Watcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,13 @@ export abstract class Watcher<T, Before extends Element, After extends Element,
protected _warning_forget_watch_ = warning({
fn: stack => console.warn('Did you forget to call `.startWatch()`?\n', stack),
})
/**
* If you're expecting Watcher may not be called, call this function, this will omit the warning.
*/
public omitWarningForForgetWatch() {
this._warning_forget_watch_.ignored = true
return this
}
private _warning_repeated_keys = warning({ once: true })
/**
* If you're expecting repeating keys, call this function, this will omit the warning.
Expand Down

0 comments on commit 8c9589f

Please sign in to comment.