feat(core): Added support for raising events
This commit is contained in:
parent
f53f89e834
commit
583abb0236
2 changed files with 29 additions and 2 deletions
|
@ -184,7 +184,9 @@ Part.prototype.shorthand = function () {
|
||||||
Path: this.Path,
|
Path: this.Path,
|
||||||
Snippet: this.Snippet,
|
Snippet: this.Snippet,
|
||||||
complete,
|
complete,
|
||||||
paperless
|
paperless,
|
||||||
|
events: this.context.events,
|
||||||
|
raise: this.context.events.raise
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,25 @@ export default function Pattern(config = { options: {} }) {
|
||||||
this.Snippet = Snippet // Snippet constructor
|
this.Snippet = Snippet // Snippet constructor
|
||||||
this.Attributes = Attributes // Attributes constructor
|
this.Attributes = Attributes // Attributes constructor
|
||||||
|
|
||||||
|
// Store events
|
||||||
|
this.events = {
|
||||||
|
info: [],
|
||||||
|
warning: [],
|
||||||
|
error: []
|
||||||
|
}
|
||||||
|
const events = this.events
|
||||||
|
this.events.raise = {
|
||||||
|
event: function (data) {
|
||||||
|
events.info.push(data)
|
||||||
|
},
|
||||||
|
warning: function (data) {
|
||||||
|
events.warning.push(data)
|
||||||
|
},
|
||||||
|
error: function (data) {
|
||||||
|
events.error.push(data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Default settings
|
// Default settings
|
||||||
this.settings = {
|
this.settings = {
|
||||||
complete: true,
|
complete: true,
|
||||||
|
@ -65,7 +84,8 @@ export default function Pattern(config = { options: {} }) {
|
||||||
config: this.config,
|
config: this.config,
|
||||||
settings: this.settings,
|
settings: this.settings,
|
||||||
store: this.store,
|
store: this.store,
|
||||||
macros: this.macros
|
macros: this.macros,
|
||||||
|
events: this.events
|
||||||
}
|
}
|
||||||
|
|
||||||
// Part closure
|
// Part closure
|
||||||
|
@ -554,6 +574,11 @@ Pattern.prototype.getRenderProps = function () {
|
||||||
props.width = this.width
|
props.width = this.width
|
||||||
props.height = this.height
|
props.height = this.height
|
||||||
props.settings = this.settings
|
props.settings = this.settings
|
||||||
|
props.events = {
|
||||||
|
info: this.events.info,
|
||||||
|
warning: this.events.warning,
|
||||||
|
error: this.events.error
|
||||||
|
}
|
||||||
props.parts = {}
|
props.parts = {}
|
||||||
for (let p in this.parts) {
|
for (let p in this.parts) {
|
||||||
if (this.parts[p].render) {
|
if (this.parts[p].render) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue