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 |
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 |
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 |
Example
myFirstFlock.remove(fooBird)
sleep()
Will sleep
every instance in the Flock
Example
myFirstFlock.sleep()
wake()
Will wake
every instance in the Flock
Example
myFirstFlock.wake()