Skip to content
This repository has been archived by the owner on Jan 6, 2025. It is now read-only.

fix(matchMediaObservable): expose observable for rxjs operators #133

Merged
merged 2 commits into from
Jan 26, 2017

Conversation

ThomasBurleson
Copy link
Contributor

@ThomasBurleson ThomasBurleson commented Jan 25, 2017

  • rename token from 'MatchMediaObservable' to ObservableMediaService
  • rename MatchMediaObservableProvider to ObservableMediaServiceProvider
  • add method .asObservable() to MediaService

BREAKING CHANGE:

  • use opaque token ObservableMediateService to inject instance of MediaService
  • use MediaService::asObservable() to get instance of observable
// RxJS
import 'rxjs/add/operator/map';

@Component({ ... })
export class MyComponent {
  constructor( @Inject(ObservableMediaService) media) {
    media.asObservable()
      .map( (change:MediaChange) => change.mqAlias == 'md' )
      .subscribe((change:MediaChange) => {
        let state = change ? `'${change.mqAlias}' = (${change.mediaQuery})` : ""
        console.log( state );
      });
  }
}

fixes #125.

@ThomasBurleson
Copy link
Contributor Author

@andrewseguin - fyi.

@andrewseguin
Copy link
Contributor

andrewseguin commented Jan 25, 2017

Presubmit looks good but you've got a fit() test in there. Can you get an LGTM or do you want me to review

@ThomasBurleson
Copy link
Contributor Author

@andrewseguin - I am changing the API. Ready tomorrow.

@ThomasBurleson ThomasBurleson force-pushed the wip/thomas/fix-match-media-observable-125 branch 4 times, most recently from aab836d to 8ca159e Compare January 26, 2017 06:00
* rename token to 'ObservableMediaService'
* rename MatchMediaObservableProvider to ObservableMediaServiceProvider
* add method `.asObservable()` to MediaService

BREAKING CHANGE:

* use opaque token `ObservableMediateService` to inject instance of `MediaService`
* use `MediaService::asObservable()` to get instance of observable

```js
// RxJS
import 'rxjs/add/operator/map';

@component({ ... })
export class MyComponent {
  constructor( @Inject(ObservableMediaService) media) {
    media.asObservable()
      .map( (change:MediaChange) => change.mqAlias == 'md' )
      .subscribe((change:MediaChange) => {
        let state = change ? `'${change.mqAlias}' = (${change.mediaQuery})` : ""
        console.log( state );
      });
  }
}
```

fixes #125.
@ThomasBurleson ThomasBurleson force-pushed the wip/thomas/fix-match-media-observable-125 branch from 8ca159e to 5cd43d9 Compare January 26, 2017 06:29
@ThomasBurleson
Copy link
Contributor Author

ThomasBurleson commented Jan 26, 2017

@andrewseguin - ready now for presubmit + merge. Thx

@andrewseguin
Copy link
Contributor

Change looks good to me, I'll add an LGTM. In the next PRs, it would be nice to have an LGTM ready on the PR before we send it off for presubmit/merge. Feel free to add anyone on the material2 team to review for future PRs

@andrewseguin
Copy link
Contributor

Needs a small change to fix some breakage. When you import ObservableMediaService, be sure to refer to the lib/media-query/observable-media-service.ts file. Some are referring to match-media.ts

@ThomasBurleson
Copy link
Contributor Author

@andrewseguin - I just fixed those import issues in the demos. Thx for that catch. LGTM now.

@andrewseguin andrewseguin merged commit 6e46561 into master Jan 26, 2017
@ThomasBurleson ThomasBurleson deleted the wip/thomas/fix-match-media-observable-125 branch February 3, 2017 16:02
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MatchMediaObservable : Upgrade from 2.0.0-beta.1 to 2.0.0-beta.3
3 participants