(Feature Request) Action wrapper in template

Open
#143 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
28/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
angular, typescript
Domain
frontend

Research direction

No files or tests are named. Start by reproducing the strict-mode failure with the [(ngModel)] examples in the issue, then inspect the Angular template binding and action-related integration points. Done means a documented, tested decision on whether an in-template action wrapper is supported, including the requested syntax or its limitation.

Written by the indexing model from the issue text.

Description

So in mobx you can wrap anythin in an action wrapper , since actions are needed to modify state.
I have the following code

<input [(ngModel)]="mystore.foo>

since its a two way binding in strict mode it complains

what I am wondering is could you add a feature so that i could do this.

<input [(ngModel)]="action(() => myStore.foo)

I'm aware of the workaround to this.
`<input [ngModel]="myStore.foo" (ngModelChange)="setMyStore($event)">/input>

setMyStore(val:string){
this.myStore.setFoo(val) //action for setting
}

Is there a feature to be able to do an in-template action wrapper

Dominant language
TypeScript
Stars
480
Forks
58
PR merge metrics
No merged PRs in 30d

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.

More from mobxjs/mobx-angular

All issues in mobxjs/mobx-angular

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.