| Module: | @ember/object |
|---|
Defined in packages/@ember/object/lib/computed/computed_macros.ts:684
import { oneWay } from '@ember/object/computed'; Where the alias computed macro aliases get and set, and allows for bidirectional data flow, the oneWay computed macro only provides an aliased get. The set will not mutate the upstream property, rather causes the current property to become the value set. This causes the downstream property to permanently diverge from the upstream property.
Example:
import { set } from '@ember/object';
import { oneWay }from '@ember/object/computed';
class User {
constructor(firstName, lastName) {
set(this, 'firstName', firstName);
set(this, 'lastName', lastName);
}
@oneWay('firstName') nickName;
}
let teddy = new User('Teddy', 'Zeenny');
teddy.nickName; // 'Teddy'
set(teddy, 'nickName', 'TeddyBear');
teddy.firstName; // 'Teddy'
teddy.nickName; // 'TeddyBear'
© 2022 Yehuda Katz, Tom Dale and Ember.js contributors
Licensed under the MIT License.
https://api.emberjs.com/ember/4.9/functions/@ember%2Fobject%2Fcomputed/oneWay