Now4realSubjectUpdate

Now4realSubjectUpdate

This class is used to notify about updates to a subscribed subject.

Constructor

new Now4realSubjectUpdate()

You cannot use this constructor directly. Interact with instances of this class through subjectUpdateCallback.

Members

(readonly) data :Object

An object that contains the update payload.

(readonly) timestamp :number

The number of milliseconds since the Unix Epoch.

(readonly) type :string

The name of the subject to which the update belongs.

Type Definitions

ConnectionStatusUpdate :Now4realSubjectUpdate

Properties:
Name Type Description
type string

"CONNECTION_STATUS"

timestamp number

The number of milliseconds since the Unix Epoch.

data object
Properties
Name Type Description
status string

A string representing the current state of the connection between the client and the Now4real cloud.

  • "CONNECTED" - The client is connected to the Now4real cloud.
  • "DISCONNECTED" - The client is currently disconnected from the Now4real cloud. It will automatically try to reconnect.
  • "DISCONNECTED:CONFIG_CHANGED" - The client was disconnected from the Now4real cloud because the configuration of the current site was changed. A page reload is required in order for the changes to take effect.
  • "DISCONNECTED:CREDIT_EXHAUSTED" - The client was disconnected from the Now4real cloud because the credit for the current site is exhausted. The API will no longer work until some credit is available again.
  • "DISCONNECTED:JWT_EXPIRED" - The client was disconnected from the Now4real cloud because the JWT used for the custom authentication is expired. A page reload is required in order to provide to the API a valid JWT token.
  • "DISCONNECTED:UNSUPPORTED_CLIENT" - The client was disconnected from the Now4real cloud because the current client version is no more supported. A page reload is required in order to get the latest version.
  • "DISCONNECTED:UNSUPPORTED_BROWSER" - The client was disconnected from the Now4real cloud because the current browser is no more supported.

CounterUpdate :Now4realSubjectUpdate

Properties:
Name Type Description
type string

The name of the counter subject to which the update belongs.

timestamp number

The number of milliseconds since the Unix Epoch.

data object
Properties
Name Type Description
value string

A string representing the updated counter subject value.
When the value is greater than 999, a rounded version of the value will be used, as shown below.

Counter range Exact value Counter example Value example
1-999 yes 128 "128"
1,000-999,999 no 1,635 "1.6K"
1,000,000 - 999,999,999 no 24,252,000 "24M"
Etc.

HeatmapUpdate :Now4realSubjectUpdate

Properties:
Name Type Description
type string

The name of the heatmap subject to which the update belongs.

timestamp number

The number of milliseconds since the Unix Epoch.

data object
Properties
Name Type Description
country string

The two-letter ISO 3166-1 alpha-2 code of the country.

intensity number

A number, from 0 to 1, representing the quantity of viewers from this country who are present in the current Page Context or Site Context. This should not be considered as a percentage but instead as a score.

LoginStatusUpdate :Now4realSubjectUpdate

Properties:
Name Type Description
type string

"LOGIN_STATUS"

timestamp number

The number of milliseconds since the Unix Epoch.

data object
Properties
Name Type Attributes Description
status string
  • "AUTHENTICATED" - The user has been successfully authenticated within the current browser.
  • "NOT_AUTHENTICATED" - The user has logged out from Now4real within the current browser.
user User <optional>

The authenticated user.
(Only available if status is "AUTHENTICATED").

persistent boolean <optional>

false if the custom authentication is being used or, in case of social login, if there are restricted privacy settings on the user browser, which prevent the library from saving the authentication object into the local storage. In that case, the login will not be remembered across page navigations. true otherwise.
(Only available if status is "AUTHENTICATED").

MessageListUpdate :Now4realSubjectUpdate

Properties:
Name Type Description
type string

"LIST_CHAT_MESSAGES"

timestamp number

The number of milliseconds since the Unix Epoch.

data object
Properties
Name Type Description
action string
  • "ADD" - The message is added to the message list.
  • "REMOVE" - The message is removed from the message list (messages should be removed after their expiry, which is controlled by the Now4real cloud because they are ephemeral).
id string

The unique identifier of the message.

message string

The message body.

author User

The user who sent the message.

timestamp number

The number of milliseconds from the Unix Epoch to the time the message was sent.

isMine boolean

Indicates whether the message was sent by the current Now4real user.

ParametersUpdate :Now4realSubjectUpdate

Properties:
Name Type Description
type string

"PARAMETERS"

timestamp number

The number of milliseconds since the Unix Epoch.

data object
Properties
Name Type Description
messageMaxLength number

The maximum number of characters that can be posted as a single message.

messageResendPeriod number

The minimum interval, in of milliseconds, required between two consecutive messages from the same user for the same pagechat.

PostStatusUpdate :Now4realSubjectUpdate

Properties:
Name Type Description
type string

"POST_STATUS"

timestamp number

The number of milliseconds since the Unix Epoch.

data object
Properties
Name Type Description
status string
  • "ENABLED" - The client is connected to the Now4real cloud, a Now4real user is authenticated in the current browser, and more than messageResendPeriod milliseconds have passed since the last message posted by this user to the current pagechat. The current user is entitled to post a new message to the current pagechat.
  • "DISABLED" - At least one of the previous three conditions is not met. The current user is not entitled to post a new message to the current pagechat.

RankingUpdate :Now4realSubjectUpdate

Properties:
Name Type Description
type string

The name of the ranking subject to which the update belongs.

timestamp number

The number of milliseconds since the Unix Epoch.

data object
Properties
Name Type Description
action string
  • "INIT" - The initial snapshot of the ranking has been completely received.
  • "ENTER" - A page has entered the ranking.
  • "UPDATE" - The page has changed its position in the ranking.
  • "LEAVE" - The page has left the ranking.
key string

The Context that uniquely identifies the page.

position number

The zero-based position index of the page in the ranking.

url string

The full URL of the page.

title string

The page title, if available, otherwise the Page Context.

users string

The counter value, following the same rules of the CounterUpdate value.

isCurrentPage boolean

Indicates whether the page is the same as the one in which the library is working.

TypingListUpdate :Now4realSubjectUpdate

Properties:
Name Type Description
type string

"LIST_CHAT_TYPING"

timestamp number

The number of milliseconds since the Unix Epoch.

data object
Properties
Name Type Description
action string
  • "START" - The user has started typing a message for the current pagechat.
  • "STOP" - The user has stopped typing a message for the current pagechat.
user User

The user who has started or stopped typing.