diff --git a/src/rule.js b/src/rule.js index 3d52fbf..98007e8 100644 --- a/src/rule.js +++ b/src/rule.js @@ -101,6 +101,7 @@ class Rule extends EventEmitter { this.ruleEvent = { type: event.type } + this.event = this.ruleEvent if (event.params) this.ruleEvent.params = event.params return this } diff --git a/test/rule.test.js b/test/rule.test.js index fc3357b..75a5fee 100644 --- a/test/rule.test.js +++ b/test/rule.test.js @@ -30,6 +30,7 @@ describe('Rule', () => { expect(rule.priority).to.eql(opts.priority) expect(rule.conditions).to.eql(opts.conditions) expect(rule.ruleEvent).to.eql(opts.event) + expect(rule.event).to.eql(opts.event) expect(rule.name).to.eql(opts.name) }) @@ -52,6 +53,7 @@ describe('Rule', () => { expect(rule.priority).to.eql(opts.priority) expect(rule.conditions).to.eql(opts.conditions) expect(rule.ruleEvent).to.eql(opts.event) + expect(rule.event).to.eql(opts.event) expect(rule.name).to.eql(opts.name) }) }) @@ -322,6 +324,7 @@ describe('Rule', () => { expect(hydratedRule.conditions).to.eql(rule.conditions) expect(hydratedRule.priority).to.eql(rule.priority) expect(hydratedRule.ruleEvent).to.eql(rule.ruleEvent) + expect(hydratedRule.event).to.eql(rule.event) expect(hydratedRule.name).to.eql(rule.name) }) @@ -333,6 +336,7 @@ describe('Rule', () => { expect(hydratedRule.conditions).to.eql(rule.conditions) expect(hydratedRule.priority).to.eql(rule.priority) expect(hydratedRule.ruleEvent).to.eql(rule.ruleEvent) + expect(hydratedRule.event).to.eql(rule.event) expect(hydratedRule.name).to.eql(rule.name) }) }) diff --git a/types/index.d.ts b/types/index.d.ts index 6dea6b8..aaa22f8 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -175,7 +175,11 @@ export class Rule implements RuleProperties { constructor(ruleProps: RuleProperties | string); name: string; conditions: TopLevelCondition; - event: Event; + /** + * @deprecated Use {@link Rule.event} instead. + */ + ruleEvent: Event; + event: Event priority: number; setConditions(conditions: TopLevelCondition): this; setEvent(event: Event): this;