Skip to content

Instantly share code, notes, and snippets.

@lxcodes
Last active August 29, 2015 14:14
Show Gist options
  • Select an option

  • Save lxcodes/76f8d0ba3b2cb1c983c7 to your computer and use it in GitHub Desktop.

Select an option

Save lxcodes/76f8d0ba3b2cb1c983c7 to your computer and use it in GitHub Desktop.

Revisions

  1. lxcodes revised this gist Feb 6, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    ### Saved from https://github.com/emberjs/ember.js/issues/5462
    #### Saved from https://github.com/emberjs/ember.js/issues/5462

    The Ghost folks have a [great implementation](https://github.com/TryGhost/Ghost/blob/master/core/client/utils/bound-one-way.js):
    ```js
  2. lxcodes revised this gist Feb 6, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    ### Saved from https://github.com/emberjs/ember.js/issues/5462

    The Ghost folks have a [great implementation](https://github.com/TryGhost/Ghost/blob/master/core/client/utils/bound-one-way.js):
    ```
    ```js
    /**
    * Defines a property similarly to `Ember.computed.oneway`,
    * save that while a `oneway` loses its binding upon being set,
  3. lxcodes revised this gist Feb 6, 2015. 1 changed file with 3 additions and 2 deletions.
    5 changes: 3 additions & 2 deletions gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    ### Saved from https://github.com/emberjs/ember.js/issues/5462

    The Ghost folks have a [great implementation](https://github.com/TryGhost/Ghost/blob/master/core/client/utils/bound-one-way.js):

    ```
    /**
    * Defines a property similarly to `Ember.computed.oneway`,
    * save that while a `oneway` loses its binding upon being set,
    @@ -21,4 +21,5 @@ var BoundOneWay = function (upstream, transform) {
    });
    };
    export default BoundOneWay;
    export default BoundOneWay;
    ```
  4. lxcodes created this gist Feb 6, 2015.
    24 changes: 24 additions & 0 deletions gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    ### Saved from https://github.com/emberjs/ember.js/issues/5462

    The Ghost folks have a [great implementation](https://github.com/TryGhost/Ghost/blob/master/core/client/utils/bound-one-way.js):

    /**
    * Defines a property similarly to `Ember.computed.oneway`,
    * save that while a `oneway` loses its binding upon being set,
    * the `BoundOneWay` will continue to listen for upstream changes.
    *
    * This is an ideal tool for working with values inside of {{input}}
    * elements.
    * @param transform: a function to transform the **upstream** value.
    */
    var BoundOneWay = function (upstream, transform) {
    if (typeof transform !== 'function') {
    //default to the identity function
    transform = function (value) { return value; };
    }
    return Ember.computed(upstream, function (key, value) {
    return arguments.length > 1 ? value : transform(this.get(upstream));
    });
    };

    export default BoundOneWay;