Skip to content

Commit

Permalink
refactor: drop ThraedListRuntime.path (#1161)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yonom authored Nov 13, 2024
1 parent fc42d01 commit 4fd56db
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 20 deletions.
4 changes: 0 additions & 4 deletions packages/react/src/api/RuntimePathTypes.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
export type ThreadListRuntimePath = {
readonly ref: string;
};

export type ThreadListItemRuntimePath = {
readonly ref: string;
readonly threadSelector:
Expand Down
20 changes: 4 additions & 16 deletions packages/react/src/api/ThreadListRuntime.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { LazyMemoizeSubject } from "./subscribable/LazyMemoizeSubject";
import { ThreadListRuntimeCore } from "../runtimes/core/ThreadListRuntimeCore";
import { Unsubscribe } from "../types";
import { ThreadListRuntimePath } from "./RuntimePathTypes";
import {
ThreadListItemRuntime,
ThreadListItemRuntimeImpl,
Expand All @@ -18,7 +17,6 @@ export type ThreadListState = {
};

export type ThreadListRuntime = {
readonly path: ThreadListRuntimePath;
getState(): ThreadListState;

subscribe(callback: () => void): Unsubscribe;
Expand Down Expand Up @@ -55,21 +53,13 @@ const getThreadListItemState = (
};
};

const THREAD_MANAGER_PATH = {
ref: "ThreadList",
};

export type ThreadListRuntimeCoreBinding = ThreadListRuntimeCore;

export class ThreadListRuntimeImpl implements ThreadListRuntime {
public get path() {
return THREAD_MANAGER_PATH;
}

private _getState;
constructor(private _core: ThreadListRuntimeCoreBinding) {
const stateBinding = new LazyMemoizeSubject({
path: THREAD_MANAGER_PATH,
path: {},
getState: () => getThreadListState(_core),
subscribe: (callback) => _core.subscribe(callback),
});
Expand All @@ -89,7 +79,7 @@ export class ThreadListRuntimeImpl implements ThreadListRuntime {
return new ThreadListItemRuntimeImpl(
new ShallowMemoizeSubject({
path: {
ref: this.path.ref + `${this.path.ref}.threadItems[${idx}]`,
ref: `threadItems[${idx}]`,
threadSelector: { type: "index", index: idx },
},
getState: () => {
Expand All @@ -105,7 +95,7 @@ export class ThreadListRuntimeImpl implements ThreadListRuntime {
return new ThreadListItemRuntimeImpl(
new ShallowMemoizeSubject({
path: {
ref: this.path.ref + `${this.path.ref}.archivedThreadItems[${idx}]`,
ref: `archivedThreadItems[${idx}]`,
threadSelector: { type: "archiveIndex", index: idx },
},
getState: () => {
Expand All @@ -124,9 +114,7 @@ export class ThreadListRuntimeImpl implements ThreadListRuntime {
return new ThreadListItemRuntimeImpl(
new ShallowMemoizeSubject({
path: {
ref:
this.path.ref +
`${this.path.ref}.threadItems[threadId=${threadId}]`,
ref: `threadItems[threadId=${threadId}]`,
threadSelector: { type: "threadId", threadId },
},
getState: () => {
Expand Down

0 comments on commit 4fd56db

Please sign in to comment.