Options
All
  • Public
  • Public/Protected
  • All
Menu

The editor module is used to edit static or dynamic text-content that is send to the output.

Typical use-cases include:

  • allows the user to edit a predefined code and updates some downstream visualization
  • display and edit a file content (pluged after the FilePicker module of the flux-files modules-box for instance)

A couple examples of flux applications can be found here.

Inputs/Outputs

The module features one input and one output.

The input of the module is not expected to convey specific data, only the configuration part of the input is used. You can overide the PersistentData properties using an adaptor for dynamic display.

The output of the module is essentially conveying the edited content (see [[ModuleEditor.Output]])

Helpers

Some ModuleEditor.helpers functions are provided to use within an adaptor.

Hierarchy

  • ModuleFlux
    • Module

Index

Constructors

constructor

  • new Module(params: any): Module

Properties

Readonly Factory

Factory: Factory

The factory of the module, i.e. its including namespace

cache

cache: Cache

Module's [[Cache | cache]], usually initialized at module construction (except if one is provided at construction).

Readonly configuration

configuration: ModuleConfiguration

The module's static configuration.

See [[ModuleConfiguration]] for a discussion about static vs dynamic configuration.

Readonly environment

environment: IEnvironment

Environment, used to:

  • fetch resources
  • send messages
  • send command to the host application

Readonly helpers

helpers: {}

A dictionary of helping objects (often functions) that can be used when writing an [[Adaptor | adaptor]] for the module.

Type declaration

  • [key: string]: any

Readonly inputSlots

inputSlots: InputSlot[] = ...

the list of inputSlots, those have to be registered at module's construction.

🤓 The number of inputs, and what they do, can depend on the module's configuration

journals

journals: Journal[] = ...

The list of available [[Journal | journals]].

This includes:

  • the journal generated while processing incoming [[Message | messages]]
  • some custom journals the developer of the module decided to expose

❕ Only the latest Journal for a particular [[Journal.title]] attribute is kept in memory.

Readonly logChannels

logChannels: LogChannel<unknown>[]

The channels of logs broadcasting, by default:

  • all logs are broadcasted to [[logs]]
  • error logs are broadcasted to [[Environment.errors$]]

Readonly logs$

logs$: ReplaySubject<Log> = ...

Observable that emits the [[Log | logs]] of the module.

Readonly moduleId

moduleId: string

module id, if not provided explicitly at construction it is a [[uuidv4]]

Readonly output$

output$: Pipe<OutputData>

Output pipe of the module

Readonly outputSlots

outputSlots: OutputSlot<any>[] = ...

the list of inputSlots, those have to be registered at module's construction.

🤓 The number of outputs, and what they do, can depend on the module's configuration

Readonly parsedData$

parsedData$: Observable<{ configCM: ConfigCodeMirror; context: any }>

Last data received and formatted

Static createEditor

createEditor: (elem: HTMLDivElement, config: ConfigCodeMirror) => any = ...

Type declaration

Methods

addInput

  • addInput(__namedParameters: { contract: IExpectation<unknown>; description?: string; id?: string; onTriggered: (__namedParameters: Object, __namedParameters: Object) => void }): void
  • Add an input to the module.

    Parameters

    • __namedParameters: { contract: IExpectation<unknown>; description?: string; id?: string; onTriggered: (__namedParameters: Object, __namedParameters: Object) => void }
      • contract: IExpectation<unknown>

        The [[contract]]: defines pre-conditions and data normalization in order to reach the triggered process

      • Optional description?: string

        description of the process triggered by the input when incoming data comes in. If not provided, 'no description available' is used.

      • Optional id?: string

        id - usually a meaningful name that is not shared with other inputs/outputs. If not provided, 'input' is used.

        ❕ if multiple inputs are added you need to provide an id to them

      • onTriggered: (__namedParameters: Object, __namedParameters: Object) => void

        The callback triggered when a message reach the input

          • (__namedParameters: Object, __namedParameters: Object): void
          • Parameters

            • __namedParameters: Object
            • __namedParameters: Object

            Returns void

    Returns void

addJournal

  • addJournal(__namedParameters: { entryPoint: Context; title: string }): void
  • Add/update a journal record (only one journal for a specific title is stored).

    Parameters

    • __namedParameters: { entryPoint: Context; title: string }
      • entryPoint: Context

        the [[Context | context]] entry point of the journal

      • title: string

        title of the journal

    Returns void

addOutput

  • addOutput<T>(__namedParameters?: { id: string }): Pipe<T>
  • The method addOutput declares a new output for the module and return a handle ([[Pipe]]) to emit value at any time.

    An output is usually used in such way:

    export class Module extends ModuleFlux {
    
         result$ : Pipe<number>
    
          constructor( params ){
             super(params) 
    
             this.addInput({
                  id:'input',
                  description: 'trigger an operation between 2 numbers',
                  contract: expectCount<number>( {count:2, when:permissiveNumber}),
                  onTriggered: ({data, configuration, context}) => 
                     this.do(data, configuration, context)
              })
             this.result$ = this.addOutput({id:'result'})
         }
    
         do( data: [number, number], configuration: PersistentData, context: Context ) {
    
             let result = operationsFactory[configuration.operationType](data)
             context.info('Computation done', {result})
             this.result$.next({data:result,context})
          }
     }
    
    

    Couple of comments:

    • The [[Pipe]] result$ is strongly typed; the trailing '$' character is a convention from RxJS to indicates that the variable is a stream.
    • We send some data into the pipe using the next method.
    • Whenever possible, it is important to forward the input context into the output pipe: (i) it ensures that user defined context in the workflow app is properly forwarded, and (ii) it allows to provide more information in the journals of execution about output emissions.

    Type parameters

    • T

    Parameters

    • __namedParameters: { id: string } = ...
      • id: string

        id - usually a meaningful name that is not share with other inputs/outputs. If not provided 'output' is used.

    Returns Pipe<T>

    A pipe that allows to emit data

fetchResources$

getInputSlot

  • getInputSlot(slotId: string): InputSlot
  • Parameters

    • slotId: string

      the slot id

    Returns InputSlot

    Matching input slot; undefined if not found

getOutputSlot

  • getOutputSlot<T>(slotId: string): OutputSlot<{ configuration: any; context: any; data: T }>
  • Type parameters

    • T = unknown

    Parameters

    • slotId: string

      the slot id

    Returns OutputSlot<{ configuration: any; context: any; data: T }>

    Matching output slot; undefined if not found

getPersistentData

  • getPersistentData<TPersistentData>(): TPersistentData
  • This function return the default PersistentData of the module. The default data can be updated at run time: the updated version is then provided to the 'onTriggered' callback defined in addInput method.

    Type parameters

    • TPersistentData

    Returns TPersistentData

    Default persistent data

getSlot

  • getSlot(slotId: string): Slot
  • Parameters

    • slotId: string

      the slot id

    Returns Slot

    Matching input or output slot; undefined if not found

log

  • log(message: any, data: any): void
  • Log a message with data in the 'console' ('console' is exposed in the [[IEnvironment | environment]]).

    Parameters

    • message: any
    • data: any

    Returns void

sendContent

  • sendContent(newContent: string, configCM: ConfigCodeMirror, context: any): void

Generated using TypeDoc