Skip to content

Commit

Permalink
fix(type): fix type and add port id
Browse files Browse the repository at this point in the history
  • Loading branch information
unadlib committed Feb 13, 2023
1 parent e96a11e commit 7ecf352
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
5 changes: 3 additions & 2 deletions packages/reactant-model/src/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
nameKey,
strictKey,
Patch,
Patches,
} from 'reactant-module';

interface Scheme<S, A> {
Expand All @@ -34,8 +35,8 @@ export const model = <
Object.assign(scheme.actions, {
[key]: (...args: any[]) => {
let state: Immutable<S> | S | undefined;
let patches: Patch[] | undefined;
let inversePatches: Patch[] | undefined;
let patches: Patches | undefined;
let inversePatches: Patches | undefined;
if (module[enablePatchesKey]) {
[state, patches, inversePatches] = create(
module[stateKey] as S,
Expand Down
6 changes: 3 additions & 3 deletions packages/reactant-module/src/decorators/action.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable no-console */
/* eslint-disable func-names */
import { create } from 'mutative';
import { Patch, ReactantAction, Service } from '../interfaces';
import { Patch, Patches, ReactantAction, Service } from '../interfaces';
import {
storeKey,
actionIdentifier,
Expand Down Expand Up @@ -67,8 +67,8 @@ const action = (
try {
const lastState = this[storeKey]?.getState();
let state: Record<string, unknown>;
let patches: Patch[] | undefined;
let inversePatches: Patch[] | undefined;
let patches: Patches | undefined;
let inversePatches: Patches | undefined;
if (this[enablePatchesKey]) {
[state, patches, inversePatches] = create(
lastState,
Expand Down
4 changes: 2 additions & 2 deletions packages/reactant-module/src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ export interface ReactantAction<T = any> extends Action<string | symbol> {
state: Record<string, T>;
params: any[];
_reactant: typeof actionIdentifier;
_patches?: Patch[];
_inversePatches?: Patch[];
_patches?: Patches;
_inversePatches?: Patches;
}

export type StateMapObject<T extends Record<string, Function>> = {
Expand Down
4 changes: 4 additions & 0 deletions packages/reactant-share/src/portDetector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ export class PortDetector {
});
}

get id() {
return this.clientId ?? '__SERVER__';
}

get shared() {
return !!(this.sharedAppOptions.port && this.sharedAppOptions.type);
}
Expand Down

0 comments on commit 7ecf352

Please sign in to comment.