Skip to content

Convert the citation to an annotation map #148

Closed

Description

@jtklein-agents

Parent

#118

What to build

One family of the page store declares its observable fields, computeds and actions in a plain annotation map instead of decorators: the citation. A family converts as a unit because decorators and annotation maps cannot be mixed within one inheritance chain.

The replacement pattern, fixed by the spec (trimmed from the prototype):

class Option {
  value;
  constructor( run, defaultValue /* … */ ) {
    this.defaultValue = defaultValue;
    this.value = defaultValue;
    makeObservable( this, {
      value: observable,
      setValue: action,
      reset: action,
      isDefault: computed,
      error: computed,
    } );
  }
  setValue( value ) { /* … */ }
}

class OutGroup extends Option {
  constructor( run ) {
    super( run, ['<none>'], 'Outgroup', '' );
    makeObservable( this, {
      options: computed,
      setValue: override, // replaces the parent action
      cmdValue: computed,
    } );
  }
  setValue( value ) { /* … */ }
}

Cut the worktree from the spec's feature branch spec/118-page-store-mobx-7 and open the pull request into it.

Acceptance criteria

  • No decorator remains on the citation.
  • Each of these classes that has observable members calls makeObservable with an explicit annotation map in its constructor. A class that needs the call and has no constructor gets one. A subclass with no observable members of its own gets no call.
  • makeAutoObservable is used nowhere.
  • An action stays an arrow field where it is passed unbound; where a subclass replaces an action, actions are prototype methods.
  • A subclass that replaces a parent's action or computed annotates it override.
  • The parity test passes with its baseline unchanged.
  • No test triggers a MobX action warning.
  • Panels and behaviour are unchanged.
  • Jest, lint, the typecheck baseline check and the end-to-end suite pass.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ready-for-agent

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions