generated from gxc-solutions/gxc-template-repo
This commit is contained in:
parent
8360edca63
commit
bc9dbd24e0
12 changed files with 20 additions and 16 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
import { isIgnorableKey, isImmutableKey } from "@gxc-solutions/model/decorators";
|
import { isIgnorableKey, isImmutableKey } from "@gxc-solutions/model-base/decorators";
|
||||||
|
import { IModel } from "@gxc-solutions/model-base/interfaces";
|
||||||
import { Subject } from "rxjs";
|
import { Subject } from "rxjs";
|
||||||
import { ICommand, ICommandExecuter, ICommandResult } from "../interfaces";
|
import { ICommand, ICommandExecuter, ICommandResult } from "../interfaces";
|
||||||
import { IModel } from "../interfaces/model";
|
|
||||||
|
|
||||||
export abstract class AbstractExecutor<T extends IModel> implements ICommandExecuter<T> {
|
export abstract class AbstractExecutor<T extends IModel> implements ICommandExecuter<T> {
|
||||||
protected _changes$ = new Subject<ICommandResult<T>[]>();
|
protected _changes$ = new Subject<ICommandResult<T>[]>();
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { IModel } from "@gxc-solutions/model/interfaces";
|
import { IModel } from "@gxc-solutions/model-base/interfaces";
|
||||||
import { IIndexer } from "../interfaces";
|
import { IIndexer } from "../interfaces";
|
||||||
import { ParallelCommandExecutor } from "./parallel-executor";
|
import { ParallelCommandExecutor } from "./parallel-executor";
|
||||||
import { Queue } from "./queue";
|
import { Queue } from "./queue";
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import { ICommand, ICommandResult, IIndexer, IModel } from "../interfaces";
|
import { IModel } from "@gxc-solutions/model-base/interfaces";
|
||||||
|
import { ICommand, ICommandResult, IIndexer } from "../interfaces";
|
||||||
import { AbstractExecutor } from "./abstract-executor";
|
import { AbstractExecutor } from "./abstract-executor";
|
||||||
import { Queue } from "./queue";
|
import { Queue } from "./queue";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import { ICommand, IIndexer, IModel } from "../interfaces";
|
import { IModel } from "@gxc-solutions/model-base/interfaces";
|
||||||
|
import { ICommand, IIndexer } from "../interfaces";
|
||||||
import { AbstractExecutor } from "./abstract-executor";
|
import { AbstractExecutor } from "./abstract-executor";
|
||||||
|
|
||||||
interface ICommandAndArg<T extends IModel> {
|
interface ICommandAndArg<T extends IModel> {
|
||||||
|
|
@ -27,7 +28,7 @@ export class SerialExecutor<T extends IModel> extends AbstractExecutor<T> {
|
||||||
this._isFlushed = true;
|
this._isFlushed = true;
|
||||||
for (const { command, object } of this._commands) {
|
for (const { command, object } of this._commands) {
|
||||||
const commandResult = await command.execute(object);
|
const commandResult = await command.execute(object);
|
||||||
const isChanged = commandResult.map(({ id, result, /*type */ }) => {
|
const isChanged = commandResult.map(({ id, result /*type */ }) => {
|
||||||
const object = this._indexer.get(id);
|
const object = this._indexer.get(id);
|
||||||
return this._apply(object, result);
|
return this._apply(object, result);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import { ICommand, ICommandResult, IIndexer, IModel } from "../interfaces";
|
import { IModel } from "@gxc-solutions/model-base/interfaces";
|
||||||
|
import { ICommand, ICommandResult, IIndexer } from "../interfaces";
|
||||||
import { AbstractExecutor } from "./abstract-executor";
|
import { AbstractExecutor } from "./abstract-executor";
|
||||||
|
|
||||||
interface ICommandAndArg<T extends IModel> {
|
interface ICommandAndArg<T extends IModel> {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
|
import { IModel } from "@gxc-solutions/model-base/interfaces";
|
||||||
import { Observable } from "rxjs";
|
import { Observable } from "rxjs";
|
||||||
import { IModel } from "./model";
|
|
||||||
|
|
||||||
export interface ICommandExecuter<T extends IModel> {
|
export interface ICommandExecuter<T extends IModel> {
|
||||||
changes$: Observable<ICommandResult<T>[]>;
|
changes$: Observable<ICommandResult<T>[]>;
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,2 @@
|
||||||
export * from "./executer";
|
export * from "./executer";
|
||||||
export * from "./indexer";
|
export * from "./indexer";
|
||||||
export * from "./model";
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { IModel } from "./model";
|
import { IModel } from "@gxc-solutions/model-base/interfaces";
|
||||||
|
|
||||||
export interface IIndexer<T extends IModel> {
|
export interface IIndexer<T extends IModel> {
|
||||||
index(page: T): void;
|
index(page: T): void;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
export type TypeOfModel = "collection";
|
|
||||||
|
|
||||||
export interface IModel {
|
|
||||||
readonly id: string;
|
|
||||||
readonly type: TypeOfModel;
|
|
||||||
}
|
|
||||||
|
|
@ -8,6 +8,7 @@
|
||||||
"registry": "https://npm.gxc-solutions.ru"
|
"registry": "https://npm.gxc-solutions.ru"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
|
"@gxc-solutions/model-base": "^0.0.1",
|
||||||
"rxjs": "^7.8.2"
|
"rxjs": "^7.8.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
6
package-lock.json
generated
6
package-lock.json
generated
|
|
@ -9,6 +9,7 @@
|
||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@gxc-solutions/model-base": "^0.0.1",
|
||||||
"rxjs": "^7.8.2"
|
"rxjs": "^7.8.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|
@ -694,6 +695,11 @@
|
||||||
"node": "^20.19.0 || ^22.13.0 || >=24"
|
"node": "^20.19.0 || ^22.13.0 || >=24"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@gxc-solutions/model-base": {
|
||||||
|
"version": "0.0.1",
|
||||||
|
"resolved": "https://npm.gxc-solutions.ru/@gxc-solutions/model-base/-/model-base-0.0.1.tgz",
|
||||||
|
"integrity": "sha512-qVx4zlSL+4dE+1fB0Jcqsh/El2ZPd+3SRsQ4iePCBgeKmmD1UUjV5qKStYoBfWYIKF9ttLsnDKvKdHREetRCDg=="
|
||||||
|
},
|
||||||
"node_modules/@humanfs/core": {
|
"node_modules/@humanfs/core": {
|
||||||
"version": "0.19.1",
|
"version": "0.19.1",
|
||||||
"resolved": "https://registry.npmjs.org/@humanfs/core/-/core-0.19.1.tgz",
|
"resolved": "https://registry.npmjs.org/@humanfs/core/-/core-0.19.1.tgz",
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@
|
||||||
"vite": "^7.3.1"
|
"vite": "^7.3.1"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@gxc-solutions/model-base": "^0.0.1",
|
||||||
"rxjs": "^7.8.2"
|
"rxjs": "^7.8.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue