mobxjs / mobxjs/mobx-utils

Use computedFn as annotation in make(Auto)Observable

Open
#296 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
1.2k
Forks
130
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the makeAutoObservable annotation handling and the computedFn entry point. Compare the existing property-based usage with the requested computedFn annotation, including bound and unbound versions; done means the class-method examples work through makeAutoObservable and are covered by the relevant tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.