Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

JS: GObject Lifecycle

GObject Lifecycle

Source code: src/gobj.js


Flags

gobj_flag_t

The features of a gobj. Each creation function below writes one combination of these, so application code rarely names them.

FlagDescription
gobj_flag_yunoThe root of the tree.
gobj_flag_default_serviceThe service that receives gobj_play() and gobj_pause().
gobj_flag_serviceA service, with a public interface of events, attributes, commands and statistics.
gobj_flag_volatilThe parent destroys it when the parent goes.
gobj_flag_pure_childIt sends its events to its parent, and nobody outside reaches it.
gobj_flag_autostartThe framework starts it.
gobj_flag_autoplayThe framework plays it.

Creation

gobj_create(gobj_name, gclass_name, kw, parent)

Builds a child gobj. It is the function that a gclass uses in mt_create.

gobj_create_yuno(gobj_name, gclass_name, kw)

Builds the root of the tree. There is one for each process.

gobj_create_service(gobj_name, gclass_name, kw, parent)

Builds a service with a name under the yuno. Only a service can be the source or the destination of a message between yunos.

gobj_create_default_service(gobj_name, gclass_name, kw, parent)

Builds the default service, which receives gobj_play() and gobj_pause().

gobj_create_volatil(gobj_name, gclass_name, kw, parent)

Builds a child that the parent destroys with itself.

gobj_create_pure_child(gobj_name, gclass_name, kw, parent)

Builds a pure child. It sends its events to its parent, and the parent must declare each one of them in its own state machine.

gobj_create2(gobj_name, gclass_name, kw, parent, gobj_flag)

Builds a gobj with the flags that the caller gives. Every function above calls it with one combination of gobj_flag_t. Use it only for a combination that no other function gives.

gobj_destroy(gobj)

Destroys a gobj. The destruction goes down: it destroys the children first. It deletes the subscriptions, and it takes the gobj out of the queue of the posted events.


Start and stop

gobj_start(gobj)

Starts a gobj, and calls its mt_start method.

gobj_stop(gobj)

Stops a gobj, and calls its mt_stop method.

gobj_start_children(gobj)

Starts the children of a gobj, and not the gobj.

gobj_stop_children(gobj)

Stops the children of a gobj.

gobj_start_tree(gobj)

Starts a gobj and each one of the gobjs below it. A gclass with the flag gcflag_manual_start does not start here.

gobj_stop_tree(gobj)

Stops a gobj and each one of the gobjs below it.


Play and pause

gobj_play(gobj)

Plays a gobj, and calls its mt_play method.

gobj_pause(gobj)

Pauses a gobj, and calls its mt_pause method.


Status

gobj_is_running(gobj)

Tells if a gobj is running.

gobj_is_playing(gobj)

Tells if a gobj is playing.

gobj_is_service(gobj)

Tells if a gobj is a service.

gobj_is_volatil(gobj)

Tells if the parent destroys this gobj with itself.

gobj_is_pure_child(gobj)

Tells if a gobj is a pure child.

gobj_is_destroying(gobj)

Tells if a gobj is under destruction. Use it in a handler of a transport that can arrive late, such as the close of a websocket.