Adds publish/subscribe pattern to allow plugins and projects to hook into events (#55)

Also adds CLI to ease development.
This commit is contained in:
Sebastian Rindom authored and GitHub committed 2020-05-07 13:47:27 +02:00
1 parent 6a78df1ecd
commit 4c2aec2838
39 files changed
+6974 -444

No files matched your search

+9
View File
@@ -0,0 +1,9 @@
{
"plugins": ["prettier"],
"extends": ["prettier"],
"rules": {
"prettier/prettier": "error",
"semi": "error",
"no-unused-expressions": "true"
}
}
@@ -0,0 +1,7 @@
{
"endOfLine": "lf",
"semi": false,
"singleQuote": false,
"tabWidth": 2,
"trailingComma": "es5"
}
+2 -3
View File
@@ -15,6 +15,8 @@
"@babel/core": "^7.7.5",
"@babel/plugin-proposal-class-properties": "^7.7.4",
"@babel/plugin-transform-runtime": "^7.7.6",
"@babel/plugin-transform-classes": "^7.9.5",
"@babel/plugin-transform-instanceof": "^7.8.3",
"@babel/preset-env": "^7.7.5",
"@babel/runtime": "^7.9.6",
"client-sessions": "^0.8.0",
@@ -28,9 +30,6 @@
"watch": "babel -w src --out-dir . --ignore **/__tests__"
},
"dependencies": {
"@babel/plugin-transform-classes": "^7.9.5",
"@babel/plugin-transform-instanceof": "^7.8.3",
"@babel/runtime": "^7.7.6",
"express": "^4.17.1",
"medusa-core-utils": "^0.3.0",
"medusa-interfaces": "^0.3.0"
@@ -0,0 +1,12 @@
class CartSubscriber {
constructor({ cartService, eventBusService }) {
this.cartService_ = cartService
this.eventBus_ = eventBusService
this.eventBus_.subscribe("cart.created", (data) => {
console.log(data)
})
}
}
export default CartSubscriber