Quantcast
Channel: Ionic Forum - Latest posts
Viewing all articles
Browse latest Browse all 230041

Mutating @Input object in child component

$
0
0

Perhaps I’m not understanding it completely, but I fear @mhartington’s suggestion. I fear anything that diffuses responsibility for holding truth. I really really like having only one place to look for things, because when there are more, I have to worry about what happens when they don’t agree.

I find JavaScript object aliasing to be a very dangerous thing to play with, for similar reasons: when objects are mutable, I have to worry about ownership semantics. If they’re not, then I don’t.

So if I were in this situation, and I wanted to propagate changes back to a parent, I would do one of two things:

  • add a corresponding @Output() property and use that channel
  • turn my child component into a ControlValueAccessor, bind it to a FormControl, and use that mechanism for managing state

Viewing all articles
Browse latest Browse all 230041

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>