o-spreadsheet
o-spreadsheet copied to clipboard
[POC] stores: bye bye reactivity 👋
Description:
description of this task, what is implemented and why it is implemented that way.
Task: : TASK_ID
review checklist
- [ ] feature is organized in plugin, or UI components
- [ ] support of duplicate sheet (deep copy)
- [ ] in model/core: ranges are Range object, and can be adapted (adaptRanges)
- [ ] in model/UI: ranges are strings (to show the user)
- [ ] undo-able commands (uses this.history.update)
- [ ] multiuser-able commands (has inverse commands and transformations where needed)
- [ ] new/updated/removed commands are documented
- [ ] exportable in excel
- [ ] translations (_t("qmsdf %s", abc))
- [ ] unit tested
- [ ] clean commented code
- [ ] track breaking changes
- [ ] doc is rebuild (npm run doc)
- [ ] status is correct in Odoo
Could be the occasion to get rid of "RENDER_CANVAS" command then since we have a new bus to work with?
diff --git a/src/components/helpers/highlight_hook.ts b/src/components/helpers/highlight_hook.ts
index 7c0edb7e0..4fb2116f5 100644
--- a/src/components/helpers/highlight_hook.ts
+++ b/src/components/helpers/highlight_hook.ts
@@ -1,12 +1,12 @@
-import { onMounted, useEffect, useEnv } from "@odoo/owl";
-import { useLocalStore } from "../../store_engine";
+import { onMounted, useEffect } from "@odoo/owl";
+import { useLocalStore, useStoreProvider } from "../../store_engine";
import { HighlightProvider, HighlightStore } from "../../stores/highlight_store";
-import { Ref, SpreadsheetChildEnv } from "../../types";
+import { Ref } from "../../types";
import { useHoveredElement } from "./listener_hook";
export function useHighlightsOnHover(ref: Ref<HTMLElement>, highlightProvider: HighlightProvider) {
const hoverState = useHoveredElement(ref);
- const env = useEnv() as SpreadsheetChildEnv;
+ const stores = useStoreProvider();
useHighlights({
get highlights() {
@@ -15,7 +15,7 @@ export function useHighlightsOnHover(ref: Ref<HTMLElement>, highlightProvider: H
});
useEffect(
() => {
- env.model.dispatch("RENDER_CANVAS");
+ stores.trigger("store-updated");
},
() => [hoverState.hovered]
);
``` @LucasLefevre WDYT?
@rrahir true. I pushed a commit :)
I think it is a fantastic idea. good job !
what would be less error prone:
class MyStore extends Store {
constructor() {...}
static mutators = ["myMytator","myOtherMutator"]
myMutator(value) { ... }
myOtherMutator(value) { ... }
myGetter() { return value; }
}
or
class MyStore extends Store {
constructor() {...}
mutators : {
myMutator = function (value) { ... },
myOtherMutator = function (value) { ... }
}
myGetter() { return value; } // if I write this.mutators.myMutator here, it's obviously a bug
}
@robodoo r+