npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ibm-wch-sdk-ng-components

v5.0.361

Published

Implementation of base components for [WCH](https://www.npmjs.com/package/ibm-wch-sdk-ng) based [Angular](https://angular.io/) applications. These base components implement business logic for commonly used scenarios but do NOT expose any markup. Subclass

Downloads

5

Readme

ibm-wch-sdk-ng-components

Implementation of base components for WCH based Angular applications. These base components implement business logic for commonly used scenarios but do NOT expose any markup. Subclass the components to provide a custom UI layer.

Usage

Install the module via

npm install --save ibm-wch-sdk-ng-components

Prereqs

AbstractNavigationComponent

Base class for components that display the site structure of WCH. The component offers properties that represent an analysis of the site structure for easy consumption, such as the currently selected page, its siblings, children, parents, etc.

Usage

Create your custom component and inherit from AbstractNavigationComponent.

import { AbstractNavigationComponent } from 'ibm-wch-sdk-ng-components';

@Component({
  ...
  changeDetection: ChangeDetectionStrategy.OnPush
})
export class NavigationComponent extends AbstractNavigationComponent implements OnInit, OnDestroy {

  constructor(aInjector: Injector) {
    super(aInjector);
  }

  // this seems to be required in order to have AOT recognize the method
  ngOnInit() {
    super.ngOnInit();
  }

  // this seems to be required in order to have AOT recognize the method
  ngOnDestroy() {
    super.ngOnDestroy();
  }

}

Note that your component has to explicitly override the OnInit and OnDestroy lifecycle methods. This is required, because the AOT build process does not detect the lifecycle implementation from a base component.

Properties

The following properties are provided out of the box.

  • onRenderingContext: Observable<RenderingContext>: RenderingContext for the currently selected page
  • onSiblings: Observable<SitePage[]>: sibilings of the currently selected page
  • onChildren: Observable<SitePage[]>: children of the currently selected page
  • onBreadcrumb: Observable<SitePage[]>: breadcrumb trail of the currently selected page
  • onParent: Observable<SitePage>: parent page of the currently selected page
  • onParents: Observable<SitePage[]>: siblings of the parent page of the currently selected page

Methods

The following methods are provided out of the box.

  • getParent: (aPage?: SitePage) => Observable<SitePage>: parent of an arbitrary page
  • getChildren: (aPage?: SitePage) => Observable<SitePage[]>: children of an arbitrary page
  • getSiblings: (aPage?: SitePage) => Observable<SitePage[]>: siblings of an arbitrary page
  • isSelected: (aPage?: SitePage) => Observable<boolean>: tests if a page is the selected page
  • trackByPageId: method to be used for a *ngFor loop over pages for performance reasons

Recommendation

Use the Observable based properties in your HTML template. You can also use them in the constructor of your custom component to build derived and compound objects using the RXJS APIs.

If all state is managed via the Observable pattern, the state of your component can only change when any of these observables fires. So we can optimize the change detection process by setting changeDetection: ChangeDetectionStrategy.OnPush on the component (see also Angular OnPush Change Detection and Component Design - Avoid Common Pitfalls).

Example

This sample shows a simple navigation rendering:

  <li class="nav-item" *ngFor='let page of onSiblings | async; trackBy: trackByPageId'>
    <a class="nav-link" [class.active]="isSelected(page) | async"  [routerLink]="page.decodedRoute">{{page.name}}</a>
  </li>