Skip to content

Commit 93269e8

Browse files
committed
feat: add deprecation usage for protected params property in ViewModelBase
1 parent 64911f6 commit 93269e8

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

src/view-model/view-model.base.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,17 @@ export class ViewModelBase<
4242

4343
protected isPayloadEqual?: PayloadCompareFn<Payload>;
4444

45-
constructor(protected params: ViewModelParams<Payload, ParentViewModel>) {
46-
this.id = params.id;
47-
this.vmConfig = mergeVMConfigs(params.config);
48-
this._payload = params.payload;
45+
/**
46+
* @deprecated use `vmParams`. This property will be removed in next major release
47+
* Reason: this word is very useful for users, so `vmParams` is more library-targered naming
48+
*/
49+
protected params: ViewModelParams<Payload, ParentViewModel>;
50+
51+
constructor(protected vmParams: ViewModelParams<Payload, ParentViewModel>) {
52+
this.params = vmParams;
53+
this.id = vmParams.id;
54+
this.vmConfig = mergeVMConfigs(vmParams.config);
55+
this._payload = vmParams.payload;
4956
this.abortController = new AbortController();
5057
this.unmountSignal = this.abortController.signal;
5158

@@ -102,13 +109,13 @@ export class ViewModelBase<
102109
}
103110

104111
protected get viewModels(): ViewModelStore {
105-
if (process.env.NODE_ENV !== 'production' && !this.params.viewModels) {
112+
if (process.env.NODE_ENV !== 'production' && !this.vmParams.viewModels) {
106113
console.error(
107114
'accessing to viewModels is not possible. [viewModels] param is not setted during to creating instance ViewModelBase',
108115
);
109116
}
110117

111-
return this.params.viewModels!;
118+
return this.vmParams.viewModels!;
112119
}
113120

114121
get isMounted() {
@@ -200,7 +207,7 @@ export class ViewModelBase<
200207
* For this property to work, the getParentViewModel method is required
201208
*/
202209
get parentViewModel() {
203-
return this.getParentViewModel(this.params.parentViewModelId);
210+
return this.getParentViewModel(this.vmParams.parentViewModelId);
204211
}
205212

206213
/**
@@ -229,7 +236,7 @@ export class ViewModelBase<
229236
parentViewModelId: Maybe<string>,
230237
): ParentViewModel {
231238
return (
232-
this.params.parentViewModel ??
239+
this.vmParams.parentViewModel ??
233240
(this.viewModels?.get(parentViewModelId) as unknown as ParentViewModel)
234241
);
235242
}

0 commit comments

Comments
 (0)