-
Notifications
You must be signed in to change notification settings - Fork 49
feat: persistent history for SDS #2741
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
| * | ||
| * If no storage backend is available, this behaves like {@link MemLocalHistory}. | ||
| */ | ||
| export class PersistentHistory extends MemLocalHistory { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you extending another class instead of the interface? Avoid abstractions as a rule of thumb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extended so that we could get the implementations for the following functions without needing to reimplement:
push(...items: ContentMessage[]): number;
some(
predicate: (
value: ContentMessage,
index: number,
array: ContentMessage[]
) => unknown,
thisArg?: any
): boolean;
slice(start?: number, end?: number): ContentMessage[];
find(
predicate: (
value: ContentMessage,
index: number,
obj: ContentMessage[]
) => unknown,
thisArg?: any
): ContentMessage | undefined;
findIndex(
predicate: (
value: ContentMessage,
index: number,
obj: ContentMessage[]
) => unknown,
thisArg?: any
): number;| this.restore(); | ||
| } | ||
|
|
||
| public override push(...items: ContentMessage[]): number { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, don't use abstraction. Its not worth the indirection you are bringing in
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
switched to composition!
| } | ||
|
|
||
| private persist(): void { | ||
| if (!this.storage) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hum, does it make sense for it to be constructed without storage?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we want the class to behave like MemLocalHistory if no storage is provided, right?
…istentHistory` to use composition over inheritance for history management.
…e key generation.
…ifying history storage initialization to default to `localStorage`
d7aa504 to
92dd0ba
Compare
size-limit report 📦
|
Problem / Description
Solution
Notes
Checklist