-
-
Notifications
You must be signed in to change notification settings - Fork 24
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
Alternative api #48
Alternative api #48
Conversation
🦋 Changeset detectedLatest commit: fd7a511 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
built with Refined Cloudflare Pages Action⚡ Cloudflare Pages Deployment
|
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 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