Closed TGlide closed 4 months ago
Latest commit: fd7a511591ea535b2c9295f7841f1af39494b84c
The changes in this PR will be included in the next version bump.
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR
Name | Status | Preview | Last Commit |
---|---|---|---|
runed | ✅ Ready (View Log) | Visit Preview | fd7a511591ea535b2c9295f7841f1af39494b84c |
I suggest we keep the external API using functions and keep classes an implementation detail. Classes have a predetermined shape and cannot be overloaded, so something like #50 would have to be separated to ReadableStore
and WritableStore
.
An alternative is to have a static method attached to the class to handle overloads.
abstract class Store<T> {
abstract value: T;
static from<T>(readable: Readable<T>): Readonly<Store<T>>
static from<T>(writable: Writable<T>): Store<T>
static from<T>(store: Readable<T> | Writable<T>): Store<T> {
if (isWritable(store)) {
return new WritableStore(store);
}
return new ReadableStore(store);
}
}
class ReadableStore<T> extends Store<T> { ... }
class WritableStore<T> extends Store<T> { ... }
I'm curious why box was removed? Just trying to learn more
Exploring some alternative APIs for our existing utilities