Skip to content
This repository has been archived by the owner on Feb 22, 2018. It is now read-only.

fix(compiler): OneWayOneTime bindings now wait for the model to stablize #1013

Closed
wants to merge 1 commit into from

Conversation

jbdeboer
Copy link
Contributor

@jbdeboer jbdeboer commented May 7, 2014

BREAKING CHANGE

Previously, OneWayOneTime bindings would remove their watch after the
first value assignment. For models that take more than one digest loop
to stablize, this meant the OneWayOneTime bindings took a un-stablized
value.

With this change, these bindings will continue to accept value
assignments until their stablized value is non-null. The assignment may
occur multiple times.

Applications to depend on OneWayOneTime bindings being called exactly
once will break. The suggested upgrade path is to move the senstive
code into a domWrite callback. e.g. the old code:

@Decorator(
    map: const { 'one-time': '=>!value' })
class OneTime {
  set value(v) => onlyCalledOnce(v);
}

becomes

@Decorator(
    map: const { 'one-time': '=>!value' })
class OneTime {
  var _value;
  set value(v) {
    if (_value == null) {
  scope.rootScope.domWrite(() => onlyCalledOnce(_value));
}
    _value = v;
  }
}

However, we expect that most uses of OneWayOneTime will be 'ok' with
being called a few times as the model stablizes.

BREAKING CHANGE

Previously, OneWayOneTime bindings would remove their watch after the
first value assignment.  For models that take more than one digest loop
to stablize, this meant the OneWayOneTime bindings took a un-stablized
value.

With this change, these bindings will continue to accept value
assignments until their stablized value is non-null. The assignment may
occur multiple times.

We expect that most uses of OneWayOneTime will be 'ok' with
being called a few times as the model stablizes.

However, applications which depend on OneWayOneTime bindings being
called exactly once will break.  The suggested upgrade path is to
move the senstive code into a domWrite callback. e.g. the old code:

    @decorator(
        map: const { 'one-time': '=>!value' })
    class OneTime {
      set value(v) => onlyCalledOnce(v);
    }

becomes

    @decorator(
        map: const { 'one-time': '=>!value' })
    class OneTime {
      var _value;
      set value(v) {
        if (_value == null) {
	  scope.rootScope.domWrite(() => onlyCalledOnce(_value));
	}
      	_value = v;
      }
    }
if ((lastOneTimeValue = dstPathFn.assign(controller, value)) != null && watch != null) {
var watchToRemove = watch;
watch = null;
scope.rootScope.domWrite(() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

domWrite sounds wrong here

@jbdeboer jbdeboer added cla: yes and removed cla: no labels May 7, 2014
@jbdeboer jbdeboer closed this in 0e12949 May 13, 2014
jbdeboer added a commit that referenced this pull request May 14, 2014
BREAKING CHANGE

Previously, OneWayOneTime bindings would remove their watch after the
first value assignment.  For models that take more than one digest loop
to stablize, this meant the OneWayOneTime bindings took a un-stablized
value.

With this change, these bindings will continue to accept value
assignments until their stablized value is non-null. The assignment may
occur multiple times.

We expect that most uses of OneWayOneTime will be 'ok' with
being called a few times as the model stablizes.

However, applications which depend on OneWayOneTime bindings being
called exactly once will break.  The suggested upgrade path is to
move the senstive code into a domWrite callback. e.g. the old code:

    @decorator(
        map: const { 'one-time': '=>!value' })
    class OneTime {
      set value(v) => onlyCalledOnce(v);
    }

becomes

    @decorator(
        map: const { 'one-time': '=>!value' })
    class OneTime {
      var _value;
      set value(v) {
        if (_value == null) {
	  scope.rootScope.domWrite(() => onlyCalledOnce(_value));
	}
      	_value = v;
      }
    }

Closes #1013
dsalsbury pushed a commit to dsalsbury/angular.dart that referenced this pull request Jul 16, 2014
BREAKING CHANGE

Previously, OneWayOneTime bindings would remove their watch after the
first value assignment.  For models that take more than one digest loop
to stablize, this meant the OneWayOneTime bindings took a un-stablized
value.

With this change, these bindings will continue to accept value
assignments until their stablized value is non-null. The assignment may
occur multiple times.

We expect that most uses of OneWayOneTime will be 'ok' with
being called a few times as the model stablizes.

However, applications which depend on OneWayOneTime bindings being
called exactly once will break.  The suggested upgrade path is to
move the senstive code into a domWrite callback. e.g. the old code:

    @decorator(
        map: const { 'one-time': '=>!value' })
    class OneTime {
      set value(v) => onlyCalledOnce(v);
    }

becomes

    @decorator(
        map: const { 'one-time': '=>!value' })
    class OneTime {
      var _value;
      set value(v) {
        if (_value == null) {
	  scope.rootScope.domWrite(() => onlyCalledOnce(_value));
	}
      	_value = v;
      }
    }

Closes dart-archive#1013
dsalsbury pushed a commit to dsalsbury/angular.dart that referenced this pull request Jul 16, 2014
BREAKING CHANGE

Previously, OneWayOneTime bindings would remove their watch after the
first value assignment.  For models that take more than one digest loop
to stablize, this meant the OneWayOneTime bindings took a un-stablized
value.

With this change, these bindings will continue to accept value
assignments until their stablized value is non-null. The assignment may
occur multiple times.

We expect that most uses of OneWayOneTime will be 'ok' with
being called a few times as the model stablizes.

However, applications which depend on OneWayOneTime bindings being
called exactly once will break.  The suggested upgrade path is to
move the senstive code into a domWrite callback. e.g. the old code:

    @decorator(
        map: const { 'one-time': '=>!value' })
    class OneTime {
      set value(v) => onlyCalledOnce(v);
    }

becomes

    @decorator(
        map: const { 'one-time': '=>!value' })
    class OneTime {
      var _value;
      set value(v) {
        if (_value == null) {
	  scope.rootScope.domWrite(() => onlyCalledOnce(_value));
	}
      	_value = v;
      }
    }

Closes dart-archive#1013
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

Successfully merging this pull request may close these issues.

2 participants