Skip to content

Commit

Permalink
rf
Browse files Browse the repository at this point in the history
  • Loading branch information
abhishiv committed Jun 24, 2024
1 parent 68f23e6 commit d323a3a
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 23 deletions.
8 changes: 0 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,6 @@ Fine grained reactive UI Library.
Router with a familiar react-router like API
</td>
</tr>
<tr>
<td>
<a href="https://github.com/abhishiv/rocky7-yjs">rocky7-yjs</a>
</td>
<td>
Bidirectional sync between Rocky7 stores and Yjs documents
</td>
</tr>
</table>

#### Sponsors
Expand Down
5 changes: 5 additions & 0 deletions src/core/state/experimental.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export type StoreManager<T = unknown> = {
wires: Set<Wire<any>>;
type: typeof Constants.STORE;
tasks: Set<{ path: string[]; observor: Function }>;
unsubscribe: Function;
};

export type StoreChange = {
Expand Down Expand Up @@ -262,6 +263,9 @@ export const createStore = <T = unknown>(
wires: new Set<Wire>(),
type: Constants.STORE,
tasks: new Set(),
unsubscribe: () => {
onChange.unsubscribe(observedObject);
},
};
const observedObject = onChange(
obj as Record<any, any>,
Expand Down Expand Up @@ -313,6 +317,7 @@ export const createStore = <T = unknown>(
storeManager.value = observedObject;
STORE_COUNTER++;
storeManager.id = "store|" + STORE_COUNTER;

return s;
};

Expand Down
20 changes: 13 additions & 7 deletions src/dom/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,17 @@ import {
createWire,
createStore,
StoreCursor,
getProxyMeta,
} from "../core/state";
import { LiveDocumentFragment } from "./dom";
import { getCursorProxyMeta } from "../utils";

export const insertElement = (
renderContext: RenderContext,
parentStep: TreeStep,
parentPath: string[],
el: VElement,
after?: string,
after?: string
) => {
console.log("insert", parentPath, el, after);

Expand All @@ -53,15 +55,15 @@ export const insertElement = (
root,
afterIndex && afterIndex > -1
? step.children[afterIndex as number]
: undefined,
: undefined
);
};

export const removeElement = (
renderContext: RenderContext,
parentStep: TreeStep,
parentPath: string[],
key: string,
key: string
) => {
const step = parentPath.reduce<TreeStep | undefined>((step, key) => {
if (!step) return;
Expand All @@ -78,7 +80,7 @@ export const updateElement = (
renderContext: RenderContext,
parentStep: TreeStep,
key: string[],
value: string,
value: string
) => {
// todo
};
Expand All @@ -87,7 +89,7 @@ export const addNode = (
renderCtx: RenderContext,
parentStep: TreeStep,
node: TreeStep,
after?: TreeStep,
after?: TreeStep
) => {
// console.log("addNode", parentStep, node, after);
const handle = (node: TreeStep) => {
Expand Down Expand Up @@ -151,8 +153,12 @@ export const removeNode = (renderCtx: RenderContext, node: TreeStep) => {
if (
step.type === DOMConstants.ComponentTreeStep &&
step.onUnmount.length > 0
)
) {
step.onUnmount.forEach((el) => el());
for (var s in step.state.stores) {
// todo unsubscribe from store
}
}
rmNodes(step.dom);
step.dom = undefined;
}
Expand Down Expand Up @@ -220,7 +226,7 @@ export const getRenderContext = (container: HTMLElement, element: VElement) => {

export const getUtils = (
renderContext: RenderContext,
parentStep: ComponentTreeStep,
parentStep: ComponentTreeStep
): Omit<ComponentUtils, "utils"> => {
return {
step: parentStep,
Expand Down
1 change: 0 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import "./object-observer.d.ts";
export * from "./dom";
export * from "./core/state";
export * from "./stdlib/index";
Expand Down
7 changes: 0 additions & 7 deletions src/object-observer.d.ts

This file was deleted.

0 comments on commit d323a3a

Please sign in to comment.