Loading...
Searching...
No Matches
JsEventLoopContract Struct Reference

Adapter for other JS modules that wish to integrate with the event loop JS module. More...

#include <js_event_loop.h>

Data Fields

JsForeignMagic magic
 
JsEventLoopObjectType object_type
 
FuriEventLoopObject * object
 
union { 
 
   JsEventLoopNonTimerContract   non_timer 
 
   JsEventLoopTimerContract   timer 
 
};  
 

Detailed Description

Adapter for other JS modules that wish to integrate with the event loop JS module.

If another module wishes to integrate with js_event_loop, it needs to implement a function callable from JS that returns an mJS foreign pointer to an instance of this structure. This value is then read by event_loop's subscribe function.

There are two fundamental variants of this structure:

  • object_type is JsEventLoopObjectTypeTimer: the timer field is valid, and the non_timer field is invalid.
  • object_type is something else: the timer field is invalid, and the non_timer field is valid. non_timer.event will be passed to furi_event_loop_subscribe. non_timer.transformer will be called to transform an object into a JS value (called an item) that's passed to the JS callback. This is useful for example to take an item out of a message queue and pass it to JS code in a convenient format. If non_timer.transformer is NULL, the event loop will take semaphores and mutexes on its own.

The producer of the contract is responsible for freeing both the contract and the object that it points to when the interpreter is torn down.


The documentation for this struct was generated from the following file: