Skip to content
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

Extend useScope incoming argument with ImpulseLikeGetter #719

Open
owanturist opened this issue Jul 5, 2024 · 0 comments
Open

Extend useScope incoming argument with ImpulseLikeGetter #719

owanturist opened this issue Jul 5, 2024 · 0 comments
Assignees

Comments

@owanturist
Copy link
Owner

The idea is to be able to work with any interface/class that extends/implements the following interface

interface ImpulseLikeGetter<TValue> {
  getValue(scope: Scope): TValue
}

so then a custom class with getValue method can be easily used as

class CustomThing {
  private readonly first: Impulse<number>
  private readonly second: Impulse<number>

  public getValue(scope: Scope): number {
    return this.first.getValue(scope) + this.second.getValue(scope)
  }
}

const x = new CustomThing()

const value = useScoped(x) // works fine
@owanturist owanturist self-assigned this Jul 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant