Options
All
  • Public
  • Public/Protected
  • All
Menu

A FluxPack gather the description of the package to be properly consumed by Flux applications. It gather some basic information as well as the registered modules and plugins.

Modules/plugins registration is done automatically when using the decorator Flux (through the [[Flux.pack]] attribute).

❕ A package meant to be consumed by Flux needs to instantiate and export a FluxPack variable with the name 'pack' (no variation). Usually it is declared in the file 'main.ts' at the higher level of your package's source

The common scenario of FluxPack initialization is to use the AUTO_GENERATED data that is generated using the 'package.json' file at the first step of the build process (when using the pipeline flux-pack of the YouWol local environment).

It follows that most of the times FluxPack initialization is only about eventually providing an install function (e.g. when fetching additional resources is needed - see Environment in such cases) .

This is a typical FluxPack initialization when no install steps are needed:

import { FluxPack } from '@youwol/flux-core'
import { AUTO_GENERATED } from '../auto_generated'
export let pack = new FluxPack(AUTO_GENERATED}

This is a typical FluxPack initialization when some install steps are needed:

import { FluxPack, IEnvironment } from '@youwol/flux-core'
import { AUTO_GENERATED } from '../auto_generated'

export function install(environment: IEnvironment){
   return environment.fetchStyleSheets(`some/url/for/css`)
}

export let pack = new FluxPack({
   ...AUTO_GENERATED, ...{ install }
})

Hierarchy

  • FluxPack

Index

Constructors

constructor

  • new FluxPack(__namedParameters: { description?: string; name: string; version: string }, install?: (Environment: any) => void | Observable<any> | Promise<any>): FluxPack
  • Parameters

    • __namedParameters: { description?: string; name: string; version: string }
      • Optional description?: string

        see version *

      • name: string

        see name

      • version: string

        see version

    • Optional install: (Environment: any) => void | Observable<any> | Promise<any>

      a function that is called when the bundle of your package has been fetched by the browser. It allows to proceed to additional installation/initialization steps before the modules get instantiated.

        • (Environment: any): void | Observable<any> | Promise<any>
        • Parameters

          • Environment: any

          Returns void | Observable<any> | Promise<any>

    Returns FluxPack

Properties

Readonly assetId

assetId: string

asset id in the YouWol's assets store

Readonly description

description: string

description of the FluxPack, the package.json description if AUTO_GENERATED fields are used

Optional Readonly install

install: (Environment: any) => void | Observable<any> | Promise<any>

Type declaration

    • (Environment: any): void | Observable<any> | Promise<any>
    • Parameters

      • Environment: any

      Returns void | Observable<any> | Promise<any>

Readonly modules

modules: {} = ...

This attributes stores the module's factory, it is populated when the decorator '@Flux' is run by the compiler

Type declaration

Readonly name

name: string

name of the fluxPack, the package.json name if AUTO_GENERATED fields are used

Readonly urlCDN

urlCDN: string

the YouWol's CDN url targeting the root folder of your package. It facilitates getting resources (javascript add-ons, bundles, stylesheets, etc) using the environment object.

e.g. to load a stylesheet included in 'dist/assets/style.css' :

import pack from 'main'

function fetch(env: Environment){
 return environment.fetchStyleSheets( `${pack.urlCDN}/dist/assets/style.css` )
}

Readonly version

version: string

version of the FluxPack, the package.json version if AUTO_GENERATED fields are used

Methods

addModule

  • addModule(moduleId: string, factory: Factory): void

getFactory

  • getFactory(moduleId: string): Factory

Generated using TypeDoc