Skip to content

Commit 1cff8b4

Browse files
committed
fix(lit-helper): logger issues
1 parent 6afa70d commit 1cff8b4

File tree

1 file changed

+20
-4
lines changed
  • packages/lit-helper/src/directives

1 file changed

+20
-4
lines changed

packages/lit-helper/src/directives/state.ts

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,23 @@ import {directive, type PartInfo} from 'lit-html/directive.js';
44

55
import {GecutAsyncDirective} from './async-directive.js';
66

7+
import type {GecutLogger} from '@gecut/logger';
8+
79
export class GecutState<T> extends GecutStateBase<T> {
810
constructor(name: string, defaultValue?: T) {
911
super(name, 'AnimationFrame');
1012

13+
this.name = name;
14+
1115
if (defaultValue != null) {
1216
this.value = defaultValue;
1317
}
1418
}
1519

20+
readonly name;
21+
1622
hydrate(render: (data: T) => unknown, loading?: () => unknown) {
17-
return __state(this, render, loading);
23+
return __state(this, render, loading, this.logger.sub('<gecut-state>'));
1824
}
1925
}
2026

@@ -29,10 +35,19 @@ class __GecutStateDirective<T> extends GecutAsyncDirective {
2935
protected _$render?: (data: T) => unknown;
3036
protected _$loading?: () => unknown;
3137

32-
render(signalState: GecutState<T>, render: (data: T) => unknown = (data) => data, loading?: () => unknown): unknown {
33-
this.log.methodArgs?.('render', {signalState});
38+
render(
39+
signalState: GecutState<T>,
40+
render: (data: T) => unknown = (data) => data,
41+
loading?: () => unknown,
42+
logger?: GecutLogger,
43+
): unknown {
44+
this.log.methodArgs?.('render', {name: signalState.name});
3445

35-
if (this._$signal && this._$render) return noChange;
46+
if (this._$signal != null) return noChange;
47+
48+
if (logger != null) {
49+
this.log = logger;
50+
}
3651

3752
this._$render = render;
3853
this._$loading = loading;
@@ -82,4 +97,5 @@ const __state = directive(__GecutStateDirective) as <T>(
8297
signalContext: GecutState<T>,
8398
render?: (data: T) => unknown,
8499
loading?: () => unknown,
100+
logger?: GecutLogger,
85101
) => unknown;

0 commit comments

Comments
 (0)