Class

Flock

Flock(…args)

Constructor

new Flock(…args)

A Flock is a way of grouping Hummingbird or even other Flock instances for a singlular way to sleep & wake every instance added to the Flock. When creating an instance simply pass in any number of instances or use the add or remove after.

Parameters:
Name Type Attributes Description
args Hummingbird | Flock <repeatable>

instances to be added on instantiation

View Source Flock.js, line 31

Example
import { Flock, Hummingbird } from 'hummingbird'

function foo() { ... }
const fooBird = Hummingbird(foo)

function bar() { ... }
const barBird = Hummingbird(bar)

function qux() { ... }
const quxBird = Hummingbird(qux)

// create a Flock (new keywork is optional)
const myFirstFlock = new Flock(fooBird, barBird)

// create another Flock and pass in a Flock instance & Hummingbird instance
const mySecondFlock = Flock(myFirstFlock, quxBird)

Methods

add(args)

Add an instance to the pool that can be controlled by the Flock methods

Parameters:
Name Type Description
args Hummingbird | Flock

instances to be added

View Source Flock.js, line 55

Example
myFirstFlock.add(quxBird)
myFirstFlock.add(function() {
 ...
})
myFirstFlock.add(() => {
 ...
})

remove(args)

remove an instance to the pool

Parameters:
Name Type Description
args Hummingbird | Flock

instances to be added

View Source Flock.js, line 64

Example
myFirstFlock.remove(fooBird)

sleep()

Will sleep every instance in the Flock

View Source Flock.js, line 75

Example
myFirstFlock.sleep()

toString()

The name of the function as as String: 'Flock'

View Source Flock.js, line 93

wake()

Will wake every instance in the Flock

View Source Flock.js, line 85

Example
myFirstFlock.wake()