Inputs.GenericInput Class
Extends Streams.SimpleStream
Defined in:
src/inputs/GenericInput.js:18
Combines multiple inputs (e.g., mouse, touch, scroll) into one unified input. Inputs must first be registered on the constructor by a unique identifier, then they can be accessed on instantiation.
Constructor
Inputs.GenericInput
(
-
inputs
-
[options]
Parameters:
Example:
// In main.js
GenericInput.register({
"mouse" : MouseInput,
"touch" : TouchInput
});
// in myFile.js
var input = new GenericInput(['mouse', 'touch'], options);
Methods
addInput
(
-
inputs
Add an input class to from the registered classes
Parameters:
-
inputs
Object | Array.Stringan array of registered input keys or an object with fields {input key : input options}
filter
(
-
filterFn
Filter converts the current stream into a new stream
that only emits if the filter condition is satisfied.
The function should return a Boolean.
Parameters:
-
filterFn
FunctionFunction to filter event payload
map
(
-
mapperFn
Map converts the current stream into a new stream
with a modified (mapped) data payload.
Parameters:
-
mapperFn
FunctionFunction to map event payload
pluck
(
-
key
Pluck is an opinionated mapper. It projects a Stream
onto one of its return values.
Useful if a Stream returns an array or an object.
register
(
static
-
inputObject
Register a global input class with an identifying key
Parameters:
-
inputObject
Objectan object of {input key : input options} fields
setOptions
(
-
options
Helper to set options on all input instances
Parameters:
-
options
Objectoptions object
split
(
-
splitterFn
Split maps one of several streams based on custom logic.
The function should return an EventEmitter.
Parameters:
-
splitterFn
FunctionSplitter function
subscribeInput
(
-
key
Subscribe events from an input class
Parameters:
-
key
Stringidentifier for input class
unsubscribeInput
(
-
key
Unsubscribe events from an input class
Parameters:
-
key
Stringidentifier for input class