Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate Observable, add ChangeNotifier, setup travis #11

Merged
merged 3 commits into from
Nov 17, 2016

Conversation

matanlurey
Copy link
Member

Partial work toward #10.

0.17.0

This is a larger change with a goal of no runtime changes for current
customers, but in the future Observable will become a very
lightweight interface, i.e.:

abstract class Observable<C extends ChangeRecord> {
  Stream<List<C>> get changes;
}
  • Started deprecating the wide Observable interface
    • ChangeNotifier should be used as a base class for these methods:
      • Observable.observed
      • Observable.unobserved
      • Observable.hasObservers
      • Observable.deliverChanges
      • Observable.notifyChange
    • PropertyChangeNotifier should be used for these methods:
      • Observable.notifyPropertyChange
    • Temporarily, Observable uses ChangeNotifier
      • Existing users of anything but implements Observable should
        move to implementing or extending ChangeNotifier. In a
        future release Observable will reduce API surface down to
        an abstract Stream<List<C>> get changes.
  • Added the ChangeNotifier and PropertyChangeNotifier classes
    • Can be used to implement Observable in a generic manner
  • Observable is now Observable<C extends ChangeRecord>
    • When passing a generic type C, notifyPropertyChange is illegal

- dev
- stable

script: ./tool/presubmit.sh
Copy link
Member

Choose a reason for hiding this comment

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

[nit] add a trailing newline

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@@ -1,3 +1,36 @@
## 0.17.0

This is a larger change with a goal of no runtime changes for current
Copy link
Member

Choose a reason for hiding this comment

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

[nit] IMO the Changelog should be more succinct and these details should stay in the commit message

Copy link
Member Author

Choose a reason for hiding this comment

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

Only reason I made this verbose is because of the implications.

/// May use [notifyChange] to queue a change record; they are asynchronously
/// delivered at the end of the VM turn.
///
/// [ChangeNotifier] may be extended, mixed in, or used as a delegate.
Copy link
Member

Choose a reason for hiding this comment

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

👍 for documenting that the class is meant to be extended

return (_changes ??= new StreamController<List<C>>.broadcast(
sync: true,
onListen: observed,
onCancel: unobserved,
Copy link
Member

Choose a reason for hiding this comment

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

[optional] If you omit the trailing comma line 31 might format nicer

Copy link
Member Author

Choose a reason for hiding this comment

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

Acknowledged.

/// May override to be notified when [changes] is first observed.
@override
@protected
@mustCallSuper
Copy link
Member

Choose a reason for hiding this comment

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

Are we mainly marking this because we assume that transitively some subclasses may need it? For future proofing?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. I'm making it more clear now.

}
}

// Will be removed when Observable removes `notifyPropertyChange`.
Copy link
Member

Choose a reason for hiding this comment

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

should we mark it as deprecated?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

@override
/*=T*/ notifyPropertyChange/*<T>*/(
Symbol field,
/*=T*/
Copy link
Member

Choose a reason for hiding this comment

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

I don't see dartfmt forcing this on its own line - did you choose it?

Copy link
Member Author

Choose a reason for hiding this comment

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

I just ran dartfmt no manual formatting.

Matan Lurey and others added 2 commits November 17, 2016 14:28
Remove stable branch, as `collection` dependency won't resolve on it.
Copy link

@jmesserly jmesserly left a comment

Choose a reason for hiding this comment

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

LGTM

@natebosch
Copy link
Member

LGTM

@matanlurey matanlurey merged commit d296efa into google:master Nov 17, 2016
@matanlurey matanlurey deleted the deprecate_observable branch November 17, 2016 23:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants