Home Reference Source
import Dryad from 'dryadic/src/Dryad.js'
public class | source

Dryad

Direct Subclass:

src/__tests__/DryadTree.js~Child, src/__tests__/DryadPlayer.js~Child, src/__tests__/hyperscript.js~GenericDryad, src/__tests__/DryadTree.js~HasSubgraph, src/__tests__/DryadTree.js~HasSubgraphWithSelf, src/__tests__/DryadTree.js~Parent, src/__tests__/DryadPlayer.js~PrepareWithFunction, src/__tests__/DryadPlayer.js~TypeOne, src/__tests__/DryadTree.js~TypeOne, src/__tests__/Dryad.js~TypeOne, src/__tests__/DryadTree.js~TypeTwo

A dryad (/ˈdraɪ.æd/; Greek: Δρυάδες, sing.: Δρυάς) is a tree nymph, or female tree spirit, in Greek mythology

A Dryad is a component for managing the creation and control of something.

For instance that 'something' could be a SuperCollider Synth, or a MIDI connection, SVG or Canvas in a webrowser, a datasource, a web resource to fetch or an external process.

It is anything that you want to specify parameters for and then create according to those parameters.

Dryads have properties and children but do not hold any internal state. Their methods are passed a context object and they perform their functionality based on their properties (what they are supposed to be / to do) and the context which holds the state, temporary variables they need for operation (like supercollider node ids) and gives them access to variables defined by parent nodes in the play graph.

They provide functionality by return command objects which are processed by command middleware which is supplied by various Dryadic packages.

Static Method Summary

Static Public Methods
public static

This method is never actually called, but merely because its implemented (MyDryad.isDryadSubclass is not undefined) it marks the thing as being a Dryad subclass.

Constructor Summary

Public Constructor
public

constructor(properties: {}, children: *[])

Subclasses should not implement constructor.

Member Summary

Public Members
public
public get

This method is never actually called, but merely because its implemented (dryad.isDryad is not undefined) it marks the things as being a Dryad.

public
public

tag: *

Method Summary

Public Methods
public

add(): *

Add the Dryad, make it play, make it start etc.

public
this method was deprecated.

Context for child; used when creating initial context for a node

public

clone(): *

public

Defaults properties if none are supplied

public

Initial context

public

Returns a command object or a function that is called with node context and will return a command object.

public

remove(): *

Remove the Dryad, make it stop etc.

public

When Dryad requires a parent Dryad to be somewhere above it then it may be specified by its class name here and the parent will be injected into the playgraph.

public

Dryad classes may return a subgraph of Dryads to replace itself in the play graph.

Static Public Methods

public static isDryadSubclass(): Boolean source

This method is never actually called, but merely because its implemented (MyDryad.isDryadSubclass is not undefined) it marks the thing as being a Dryad subclass.

Return:

Boolean

Public Constructors

public constructor(properties: {}, children: *[]) source

Subclasses should not implement constructor. All Dryad classes take properties and children.

Params:

NameTypeAttributeDescription
properties {}
  • optional
  • default: {}
children *[]
  • optional
  • default: []

Public Members

public children: * source

public get isDryad: Boolean: boolean source

This method is never actually called, but merely because its implemented (dryad.isDryad is not undefined) it marks the things as being a Dryad.

Return:

Boolean

public properties: * source

public tag: * source

Public Methods

public add(): * source

Add the Dryad, make it play, make it start etc.

Returns a command object or a function that is called with node context and will return a command object.

Middleware supplied by layers will match command keys and will be passed the value. Value is either an object that the middleware uses to do whatever it does (launch things, send messages) or is a function that take context and returns the object.

Command middleware for add may return Promises which resolve on success; ie. when the thing is successfully booted, running etc.

Return:

*

public childContext(): * source

this method was deprecated.

Context for child; used when creating initial context for a node

Note that the child already inherits from this context.

will deprecate this. nothing is using it

Return:

*

public clone(): * source

Return:

*

public defaultProperties(): * source

Defaults properties if none are supplied

Return:

*

public initialContext(): * source

Initial context

This dryad's context is also the parent object for all children.

Return:

*

public prepareForAdd(): * source

Returns a command object or a function that is called with node context and will return a command object.

Values of the command objects are functions may return Promises, and may reject those promises which will halt the .add() operation

The function is called with the node's context

Middleware supplied by layers will match command keys and will be passed the value. Value is either an object that the middleware uses to do whatever it does (launch things, send messages) or is a function that take context and returns the object.

Return:

*

public remove(): * source

Remove the Dryad, make it stop etc.

Returns a command object or a function that is called with node context and will return a command object.

Middleware supplied by layers will match command keys and will be passed the value. Value is either an object that the middleware uses to do whatever it does (launch things, send messages) or is a function that take context and returns the object.

Command middleware for run may return Promises which resolve on success; ie. when the thing is successfully stopped, remove etc.

Return:

*

public requireParent(): String | undefined source

When Dryad requires a parent Dryad to be somewhere above it then it may be specified by its class name here and the parent will be injected into the playgraph. This is similar to subgraph() but make it easy to do and is less error prone.

Example: SCSynthDef compiles SynthDefs from source code and requires a supercollider SCLang interpreter as a parent to do that compilation. If there is not already an SCLang in the play graph then include one.

Return:

String | undefined

class name of required parent Dryad

public subgraph() source

Dryad classes may return a subgraph of Dryads to replace itself in the play graph. This lets Dryads compose more complex behavior, add other Dryads that assist. Any Dryads supplied in properties should be included in the subgraph.

The subgraph may also contain the Dryad itself in which case its .add .remove will be called. If subgraph is implemented but it does not include itself then .add / .remove will not be called.