Skip to content

Custom almanac #357

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

Merged
merged 3 commits into from
Nov 10, 2023
Merged

Custom almanac #357

merged 3 commits into from
Nov 10, 2023

Conversation

chris-pardy
Copy link
Collaborator

This is a generic suggestion to resolve #314

Rather than having the Almanac class be completely hidden except in event properties we move to having the Almanac be an option that can be passed into the run call. This allows for extensions of Almanacs that can do things that the standard Almanac can't do.
In order to support this properly a new addFact method was added to the Almanac that replaces the addRuntimeFact method but also allows dynamic facts to be added.

The addFact method is stright from the engine class. It's able
to either add a fact with a name and value / implementation
or add a fact as a fact subclass.
Move the Almanac Initialization into the engine class. This will allow
it to take user supplied Almanacs correctly.
Support for passing a custom almanac to the run options in the engine.
Copy link
Owner

@CacheControl CacheControl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delayed review, looks great. Very cool!

@chris-pardy chris-pardy merged commit fff169d into CacheControl:master Nov 10, 2023
@chris-pardy chris-pardy deleted the custom-almanac branch November 10, 2023 08:44

```js
// constant facts:
engine.addFact('speed-of-light', 299792458)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a mistake, engine.addFact should be almanac.addFact

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

Successfully merging this pull request may close these issues.

3 participants