Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explore one existing pico-engine library #9

Open
windley opened this issue Jan 24, 2024 · 3 comments
Open

Explore one existing pico-engine library #9

windley opened this issue Jan 24, 2024 · 3 comments
Assignees

Comments

@windley
Copy link
Member

windley commented Jan 24, 2024

  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 keylanjensen self-assigned this Jan 31, 2024
@keylanjensen
Copy link
Collaborator

  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
Copy link
Collaborator

  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 vmoreno02 self-assigned this Feb 2, 2024
@vmoreno02
Copy link
Collaborator

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.

@windley windley changed the title Explore one existing pico-engine module Explore one existing pico-engine library Feb 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants