noolsjs / nools

Rete based rules engine written in javascript
http://noolsjs.com/
MIT License
950 stars 181 forks source link

Adding new object definition from js #93

Open CarloAl opened 10 years ago

CarloAl commented 10 years ago

Is it possible to add a fact definition dynamically from js?

Something like:

flow.define(myFact, {myFact:'myFact'})

the only way I have found is to add to the flow.__defined the function createDefine declared in compile/common.js, but I am not sure if nools also do something behind the scenes that would break this workaround.

doug-martin commented 10 years ago

Checkout nools.compile there is a define option you can use that allows you to specify custom fact types.

CarloAl commented 10 years ago

That's cool but it's only at compile time no?

I cannot add one after I have already called compile

(I think it would be a good enhancement also if it would be possible to add rule to after compiling)