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 computedFn as annotation in make(Auto)Observable #296

Open
grasshoppergn opened this issue May 6, 2021 · 2 comments
Open

Use computedFn as annotation in make(Auto)Observable #296

grasshoppergn opened this issue May 6, 2021 · 2 comments

Comments

@grasshoppergn
Copy link

grasshoppergn commented May 6, 2021

It seems that the only way now to use computedFn in model classes is

class Model {
  getSomething = computedFn((params) => "return something");
  constructor() {
    makeAutoObservable(this, {
      getSomething: false,
    });
  }
}

So it looks quite convenient to allow computedFn to be used as an annotation, so it becomes

class Model {
  getSomething(params) {
    return "return something";
  }
  constructor() {
    makeAutoObservable(this, {
      getSomething: computedFn,
    });
  }
}

Can also be done with bounds / not bound versions

@whalemare
Copy link

Duplicate of #236

@grasshoppergn
Copy link
Author

@whalemare is it? #236 doesn't automatically make it useful in makeAutoObservable...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants