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

explicit export types #140

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

explicit export types #140

wants to merge 1 commit into from

Conversation

alverdal
Copy link

@alverdal alverdal commented Oct 9, 2023

Explicit export of api types to allow for a more flexible use of rule definitions and this library.
Currently, only RuleEngine is exported in the dist/index.d.ts but it would be nice to have the other types exported as well.

For instance, to be able to define rules as re-useable functions and defining rules as separate variable.

const rules: Rule[] = [
   myReuseableFunction(api, fact)
  ,{
    name: 'ageOfDog',
    priority: 1,
    condition: (api: API, fact: Fact) => {
      api.when(fact.age > 5)
    },
    consequence: (R: API, fact: Fact) => {
      fact.result = false
      fact.reason = 'The dog is older than 5 years.'
      R.stop()
    }
  }
]

eng.register(rules)

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.

None yet

2 participants