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

Use BehaviorSubject for CasedObject #11

Open
replygirl opened this issue Sep 5, 2020 · 0 comments
Open

Use BehaviorSubject for CasedObject #11

replygirl opened this issue Sep 5, 2020 · 0 comments
Labels
enhancement New feature or request

Comments

@replygirl
Copy link
Owner

replygirl commented Sep 5, 2020

Make a CasedObject instance and its value and options subscribable

Something like...

class CasedObject extends BehaviorSubject {
  private _options = new BehaviorSubject({})
  private _value = new BehaviorSubject({})

  // ...

  constructor(value: any, options: CasedObjectOptions) {
    this.options.next(options)

    const { case: c } = options
    this.value.next(!!case ? changeCase(c, value) : c)
  }

  // ...

  private proxied(p: string) {
    return new Proxy([this[p], {
      get: (_x, k) => this[p].value[k],
      set: (_x, k, v) => this[p].next({ ...this[p].value, [k]: v })
    }])
  }
}
@replygirl replygirl changed the title Use BehaviorSubject Use BehaviorSubject for CasedObject Sep 5, 2020
@replygirl replygirl added the enhancement New feature or request label Sep 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant