0.3.13 • Published 4 years ago

@ciklum-toggler/angular-sdk v0.3.13

Weekly downloads
15
License
Apache-2.0
Repository
github
Last release
4 years ago

@ciklum-toggler/angular-sdk

@ciklum-toggler/angular-sdk is easy way to integrate your angular application with ciklum toggler feature flags provider

Getting started

  • Run npm i -S @ciklum-toggler/angular-sdk or yarn add @ciklum-toggler/angular-sdk to install module as dependency
  • Import components from module to your app.module (root)
import {
     FeatureToggleModule,
     FEATURE_TOGGLE_CONFIG_TOKEN,
     FeatureToggleConfig,
   } from '@ciklum-toggler/angular-sdk';
  • Configure module settings
    • add module to imports in the @NgModule
    • add value for toggleUrl - path to your instance of Ciklum Toggler and api endpoint mostly it's /api/external-systems-access
    • add value for envKey - sdk token for your environment
imports: [
    ...
    FeatureToggleModule.forRoot({
      provide: FEATURE_TOGGLE_CONFIG_TOKEN,
      useFactory: (): FeatureToggleConfig => ({
        toggleUrl: '${path-to-your-instance}/api/external-systems-access',
        envKey: 'unique-env-sdk-key',
      })
    })
    ...
  ],

Usage

Directives

Example

<h2 *featureToggle="featureToggleName">FF is enabled</h2>
<h2 *featureToggleWhenDisabled="featureToggleName">FF when disabled</h2>

Service

Example

Import service where you are going to use it

import { FeatureToggleService } from '@ciklum-toggler/angular-sdk';

Usage service in your code

export class MyComponent implements OnInit {
  public readonly featureToggleName = 'FEATURE_NAME';
  constructor(private featureToggleService: FeatureToggleService) {

  }
  ngOnInit(): void {
    this.featureToggleService.isEnabled(this.featureToggleName)
      .subscribe((isEnabled) => {
        ...your implementation here...
      });
  }
}

CanActivateGuard

  • provide data with feature name to you route
  • add FeatureGuard to you route
import { FeatureGuard } from '@ciklum-toggler/angular-sdk'; 

const moduleRoutes: Routes = [
    {
        path: RUTER_PATH,
        component: 'MyComponent',
        data: {
            feature: string, //-ff name
        },
        canActivate: [FeatureGuard]
    }
]

CanLoadGuard

  • provide data with feature name to you route
  • add FeatureLoadGuard to you route
import { FeatureGuard } from '@ciklum-toggler/angular-sdk'; 

const moduleRoutes: Routes = [
    {
        path: RUTER_PATH,
        component: 'MyComponent',
        data: {
            feature: string, //-ff name
        },
        canLoad: [FeatureLoadGuard]
    }
]

API

  • Directives
    • featureToggle - render layout when feature is enabled
    • featureToggleWhenDisabled - render layout when feature is disabled
  • Service
    • FeatureToggleService.isEnabled - check if feature is enabled and return Observable, unsubscription isn't needed
  • Guards
    • CanActivateGuard - FeatureGuard
    • CanLoadGuard - FeatureLoadGuard
0.3.13

4 years ago

0.3.12

4 years ago

0.3.11

4 years ago

0.3.9

4 years ago

0.3.10

4 years ago

0.3.8

4 years ago

0.3.7

4 years ago

0.3.4

4 years ago

0.3.3

4 years ago

0.3.2

4 years ago

0.3.1

4 years ago

0.3.0

4 years ago

0.2.2

4 years ago

0.0.0

4 years ago