Picolab / pico-pods

Linking picos to Solid pods
0 stars 0 forks source link

Explore one existing pico-engine library #9

Open windley opened 5 months ago

windley commented 5 months ago
  1. Where does it live in the code base?
  2. How does it expose its functions?
  3. How does it expose its events?

Write a 1-page document with the results.

keylanjensen commented 5 months ago
  1. Where does it live in the code base? Modules in the project codebase are in the pico-engine/packages/pico-engine-core/src/modules directory as .ts files. The specific module I’m looking at is the HTTP library, and is the http.ts file.
  2. How does it expose its functions? The module uses the export declaration to export a function for initializing the module. This function accepts the Pico engine’s core as an argument which is passed down to the KRL functions it creates for the module. The module constant which is returned by the function and houses the set of functions the module provides access to is created using krl.Module.
  3. How does it expose its events? The module uses this.rsCtx.raiseEvent() and core.picoFramework.Event() to provide events for the Pico engine. The former is used to raise an event when an operation in the module is run, while the latter is used to enable the developer/user to pass in an event via a map to send to a Pico once the HTTP response becomes available.
KyerHarris commented 5 months ago
  1. time.ts. part of pico-engine-core/src/modules included in all Picos
  2. The file exports time, which uses the KRL function opts to get options from the caller.
  3. it doesn't call any events, but is called by picos when they need to get the datetime.
vmoreno02 commented 5 months ago

Where does it live in the code base? The schedule module lives with the other built-in modules in pico-engine/packages/pico-engine-core/src/modules. Its name is schedule.ts.

How does it expose its functions? The functions are exported in the Javascript function initScheduleModule. They use an internal Scheduler object that keeps track of all the scheduled events.

How does it expose its events? The module exports the type ScheduledEvent, which is defined as one of two related interfaces, ScheduledEvent_at and ScheduledEvent_repeat.