Skip to content

Commit

Permalink
update reactivity core
Browse files Browse the repository at this point in the history
  • Loading branch information
MrWangJustToDo committed Oct 31, 2024
1 parent ce96039 commit 364aabd
Show file tree
Hide file tree
Showing 5 changed files with 4,161 additions and 3,437 deletions.
2 changes: 2 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
prefer-workspace-packages=true
link-workspace-packages=true
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"engines": {
"node": ">=10"
},
"packageManager": "pnpm@8.9.0",
"packageManager": "pnpm@9.12.0",
"scripts": {
"dev:packages": "ts-node ./scripts/rollupWatch.ts",
"build:packages": "ts-node ./scripts/rollupBuild.ts",
Expand All @@ -29,12 +29,12 @@
}
},
"devDependencies": {
"@algolia/client-search": "^4.21.1",
"@shikijs/twoslash": "^1.22.0",
"@shikijs/vitepress-twoslash": "^1.22.0",
"@swc/core": "^1.7.14",
"@types/lodash": "^4.17.7",
"@types/node": "^22.5.0",
"@algolia/client-search": "^4.24.0",
"@shikijs/twoslash": "^1.22.2",
"@shikijs/vitepress-twoslash": "^1.22.2",
"@swc/core": "^1.7.40",
"@types/lodash": "^4.17.13",
"@types/node": "^22.8.5",
"@types/react": "^18.2.79",
"@types/react-dom": "^18.2.25",
"eslint": "^8.57.0",
Expand All @@ -46,12 +46,12 @@
"react-dom": "^18.2.0",
"reactivity-store": "workspaces: *",
"search-insights": "^2.17.0",
"shiki": "^1.22.0",
"shiki": "^1.22.2",
"ts-node": "^10.9.2",
"tslib": "^2.7.0",
"tslib": "^2.8.0",
"typescript": "^5.3.3",
"vitepress": "^1.3.4",
"vue": "^3.4.38",
"vue": "^3.5.12",
"zustand": "^5.0.0"
}
}
4 changes: 2 additions & 2 deletions packages/r-store/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@
"state-management, reactive, vue, react"
],
"dependencies": {
"@vue/reactivity": "^3.4.38",
"@vue/shared": "^3.4.38",
"@vue/reactivity": "^3.5.12",
"@vue/shared": "^3.5.12",
"jsan": "^3.1.14",
"use-sync-external-store": "^1.2.2"
},
Expand Down
28 changes: 16 additions & 12 deletions packages/r-store/src/shared/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,19 +90,9 @@ export class Controller<T = any> {
) {
this._getStateSafe = catchError(_getState, this);

this._effect = new ControllerEffect(this._getStateSafe, () => {
this.run();
this._effect = new ControllerEffect(this._getStateSafe);

if (!this._isActive) return;

if (this._lifeCycle.canUpdateComponent) {
if (this._lifeCycle.syncUpdateComponent) {
this.notify();
} else {
queueJob(this);
}
}
});
this._effect.scheduler = this._scheduler;

if (
this._namespace !== InternalNameSpace.$$__persist__$$ &&
Expand Down Expand Up @@ -142,6 +132,20 @@ export class Controller<T = any> {
this._listeners.forEach((f) => f());
};

_scheduler = () => {
this.run();

if (!this._isActive) return;

if (this._lifeCycle.canUpdateComponent) {
if (this._lifeCycle.syncUpdateComponent) {
this.notify();
} else {
queueJob(this);
}
}
};

subscribe = (listener: () => void) => {
this._listeners.add(listener);

Expand Down
Loading

0 comments on commit 364aabd

Please sign in to comment.