Show:
Defined in: src/js/dsl/dsl.js:156
Module: proact-dsl

Contains implementation of the ProAct.js DSL.

The idea of the DSL is to define ProAct.Actors and their dependencies on each other in a declarative and simple way.

The ProAct.Registry is used to store these actors.

For example if we want to have a stream configured to write in a property, it is very easy done using the DSL:

   ProAct.registry.prob('val', 0, '<<(s:data)');
 
This tells the ProAct.Registry to create a ProAct.Property with the value of zero, and to point the previously, stored 'data' stream to it.

Item Index

Methods

Properties

Methods

defPredefined

(
  • type
  • id
  • operation
)
static

Defines a new predefined function to be reused in the DSL.

For example:

  ProAct.DSL.defPredefined('filter', 'enter', function (event) {
   return event.keyCode === 13;
  });

creates a new filtering function, which can be used like this:

  actor2 = actor1.filter('enter');

the actor2 in this case will recieve only the events with keyCode of 13.

Parameters:

  • type String

    One of the three -> mapping, filtering and accumulation types.

  • id String

    The identificator of the predefined function to be passed to trasfromation or filtering operations.

  • operation Function | Array

    The implementation of the operation.

optionsFromArray

(
  • optionArray
  • [...]
)
Object static

Extracts DSL actions and options from an array of strings.

Example optionArray is ['map($1)', 'filter(+)', @($2)'] and it will become options object of functions and arguments to be applied on a target ProAct.Actor passed to the ProAct.DSL/run:method method.

Parameters:

  • optionArray Array

    The array of strings to use to extract options from.

  • [...] Object optional

    Parameters for the extracted actions/functions/operations.

    For example if the array contains 'map($1)', the first argument passed after the optionArray argument is passed to the 'map' operation.

Returns:

Object:

Object containing operations as fields and options(arguments) for these operations as values.

['map($1)', 'filter(+)', @($2)'] becomes:

         {
           mapping: {first-argument-to-this-function-after-the-optionString-arg},
           filtering: ProAct.DSL.predefined.filtering['+'],
           on: {second-argument-to-this-function-after-the-optionString-arg}
         }
       

optionsFromString

(
  • optionString
  • [...]
)
Object static

Extracts DSL actions and options from a string.

Splits the passed optionString using separator as saparator and calls optionsFromArray on the result.

Parameters:

  • optionString String

    The string to use to extract options from.

  • [...] Object optional

    Parameters for the extracted actions/functions/operations.

    For example if the string contains 'map($1)', the first argument passed after the optionString argument is passed to the 'map' operation.

Returns:

Object:

Object containing operations as fields and options(arguments) for these operations as values.

'map($1)|filter(+)|@($2)' becomes:

         {
           mapping: {first-argument-to-this-function-after-the-optionString-arg},
           filtering: ProAct.DSL.predefined.filtering['+'],
           on: {second-argument-to-this-function-after-the-optionString-arg}
         }
       

(
  • actor
  • options
  • registry
  • [...]
)
ProAct.Actor static

Configures an ProAct.Actor using the DSL passed with the options argument.

Uses the passed ProAct.Registry to read stored values from.

Parameters:

  • actor ProAct.Actor

    The target of the DSL operations.

  • options ProAct.Actor | String | Object

    The DSL formatted options to be used for the configuration.

    If the value of this parameter is instance of ProAct.Actor it is set as a source to the target actor.

    If the value ot this parameter is String - optionsFromString is used to be turned to an options object.

    If the values of this parameter is object, it is used to configure the targed actor.

    The format of the object should be something like:

             {
               dsl-operation: function|array-of-functions-and-arguments,
               dsl-operation: function|array-of-functions-and-arguments,
               dsl-operation: function|array-of-functions-and-arguments,
               ...
             }
           

  • registry ProAct.Registry

    The registry to read stored values for the DSL operations.

    For example if there is 'map(f:foo)', the mapping function is read from the registry at the key 'foo'.

  • [...] Object optional

    Parameters for the DSL operations.

    For example if the array contains 'map($1)', the first argument passed after the actor, options and registry arguments is passed to the 'map' operation.

Returns:

ProAct.Actor:

The configured actor.

Properties

separator

String final

A separator which can be used to separate multiple DSL expressions in one string.