Skip to content
This repository was archived by the owner on Dec 18, 2024. It is now read-only.

Disambiguate between material and cdk docs #286

Merged
merged 2 commits into from
Nov 2, 2017

Conversation

jelbourn
Copy link
Member

Goes along with angular/components#7675.

I've done some ugly things here- any suggestions on cleaning it up without hard-coding a bunch of repetitive stuff?

I'm also doing something weird with the router because I don't know the real way.

]
};

for (let category of DOCS[COMPONENTS]) {
Copy link
Contributor

Choose a reason for hiding this comment

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

You could probably combine these loops into one w/ something like this:

for (const type in DOCS) {
  for (const cat of DOCS[type]) {
    for (let doc of cat.items) {
      doc.packageName = cat;
    }
  }
}

Copy link
Member Author

Choose a reason for hiding this comment

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

The packageName isn't the category; the categories are things like forms, layout, etc.

The type also isn't the package name, it's the section name ("components" and "cdk").

Copy link
Member Author

Choose a reason for hiding this comment

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

What I really want to do is generate this entire blob.

this._fragmentSubscription.unsubscribe();
this._routeSubscription && this._routeSubscription.unsubscribe();
this._scrollSubscription && this._scrollSubscription.unsubscribe();
this._fragmentSubscription && this._fragmentSubscription.unsubscribe();
Copy link
Contributor

Choose a reason for hiding this comment

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

This might be a nice time to use takeUntil so you don't have to manage all the subscriptions

private _onDestroy = new Subject<void>();

constructor() {
  this._router.events
    .takeUntil(this._onDestroy)
    .subscribe();
}

ngOnDestroy() {
  this._onDestroy.next();
  this._onDestroy.complete();
}

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

this.componentDocItem = docItems.getItemById(params['id']);
this.componentDocItem = docItems.getItemById(
params['id'],
this._route.parent.snapshot.params['section']);
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe?

Observable.combineLatest(this._route.params.pluck('id'), this._route.parent.params.pluck('section'))
  .map(([id, section]) => docItems.getItemById(id, section))
  .takeUntil(this._onDestroy)
  .subscribe(docItem => ...);

Copy link
Member Author

Choose a reason for hiding this comment

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

Good suggestion; the typings for pluck are messy, so I did it manually from the tuple type

    Observable.combineLatest(_route.params, _route.parent.params)
        .map((p: [Params, Params]) => ({id: p[0]['id'], section: p[1]['section']}))
        .map(p => docItems.getItemById(p.id, p.section))
        .subscribe(d => {...});

@jelbourn
Copy link
Member Author

I don't have a better idea for marking the package, so open for real review

@andrewseguin
Copy link
Collaborator

Needs rebase

@jelbourn
Copy link
Member Author

jelbourn commented Nov 2, 2017

@andrewseguin rebased

Copy link
Collaborator

@andrewseguin andrewseguin left a comment

Choose a reason for hiding this comment

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

LGTM

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.

5 participants