new module:ct-services /testing /Record Stub(subject, initial Field Data, generators)
Created by module:ct-services/testing/MessageServiceStub
as a representation of a record that can be subscribed
to. Used to send updated field data to subscribers, and to monitor the number of subscriptions made for the record's
subject.
This class uses emitr.
Parameters:
Name | Type | Description |
---|---|---|
subject |
String | The subject for this record |
initialFieldData |
Object | Data fields that will be sent to component when it subscribes. If provided, these will also be editable by user in workbench tool. |
generators |
Array | List of data generators. |
Members
(static) EVENTS
A map of events that this class may trigger.
Contains the following events:
- DATA_CHANGED
-
Triggered when some of the record's field data has changed.
PARAMETERS
{Map} updatedFields A map of field names to their new values. - STATUS_CHANGED
- Triggered when the record's status has changed.
- SUBSCRIPTIONS_CHANGED
-
Triggered when a record stub's number of all subscriptions, or number of paused subscriptions changes.
PARAMETERS
module:ct-services/testing/RecordStub
record The record stub that fired the event. - ERROR
-
Triggered when the record stub is put into an error state.
PARAMETERS
module:ct-services/messaging/SubscriptionError
type The error type.
Methods
add Data Generator(generator ToAdd)
Adds a module:ct-workbench/model/DataGenerator
to this record, which will then be used to auto-generate data
updates, using the record's initial values as seeds. The update rate can be set using
module:ct-services/testing/RecordStub#setUpdateInterval
.
Parameters:
Name | Type | Description |
---|---|---|
generatorToAdd |
module:ct-workbench |
The data generator that should be used to generate auto updates for this record. |
clear Update Interval()
Stops this record from providing automatic updates.
get Field Data() → {Map}
Gets a map of all the record's fields and their values.
Returns:
A map of all field data for this record.
- Type
- Map
get Paused Subscription Count() → {Number}
Returns the number of paused subscriptions there are for this record.
Returns:
The number of paused subscriptions for this record.
- Type
- Number
get Status() → {module:ct-services /messaging /Subscription Status}
Gets the current status of the record.
Returns:
The current status of the record.
get Subject() → {String}
Gets the subject that maps to this record.
Returns:
The subject of the record.
- Type
- String
get Subscription Count() → {Number}
Returns the number of subscriptions there are for this record. This includes both active and paused subscriptions.
Returns:
the number of subscriptions for this record.
- Type
- Number
remove Data Generator(generator ToRemove)
Parameters:
Name | Type | Description |
---|---|---|
generatorToRemove |
module:ct-workbench |
The data generator that should no longer be used to generate auto updates for this record. |
set Error Type({@link)
Sets the error type of this record, and then informs all listeners of the change.
Parameters:
Name | Type | Description |
---|---|---|
{@link |
module:ct-services/messaging/SubscriptionError} errorType The type of error that this record is in. |
set Field Data(data Updates, meta Data)
Sets new values for fields on this record, and then informs all subscribers of the change.
Parameters:
Name | Type | Description |
---|---|---|
dataUpdates |
Map | A map of new field values. |
metaData |
Map | A map of meta data |
set Status(status)
Sets the status of the record {@see module:ct-services/messaging/SubscriptionStatus}.
Parameters:
Name | Type | Description |
---|---|---|
status |
module:ct-services |
The new status of this record. |
set Update Interval(interval Period)
Sets the update rate of generated data for this record {@see module:ct-services/testing/RecordStub#addDataGenerator}.
Parameters:
Name | Type | Description |
---|---|---|
intervalPeriod |
Number | The time in milliseconds between auto-generated data updates for this record. |