@universal-packages/dynamic-api
Advanced tools
Comparing version 1.2.0 to 1.3.0
@@ -0,3 +1,5 @@ | ||
/// <reference types="node" /> | ||
import { EventEmitter } from 'stream'; | ||
import { DynamicApiOptions, Dynamics } from './DynamicApi.types'; | ||
export default class DynamicApi<D extends Record<string, any>> { | ||
export default class DynamicApi<D extends Record<string, any>> extends EventEmitter { | ||
readonly options: DynamicApiOptions; | ||
@@ -4,0 +6,0 @@ readonly dynamics: Dynamics; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const module_loader_1 = require("@universal-packages/module-loader"); | ||
class DynamicApi { | ||
const stream_1 = require("stream"); | ||
class DynamicApi extends stream_1.EventEmitter { | ||
constructor(options) { | ||
super(); | ||
this.dynamics = {}; | ||
@@ -7,0 +9,0 @@ this.options = { ...options }; |
{ | ||
"name": "@universal-packages/dynamic-api", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"description": "Dynamic decoupling-adapting system", | ||
@@ -5,0 +5,0 @@ "author": "David De Anda <david@universal-packages.com> (https://github.com/universal-packages)", |
@@ -164,2 +164,22 @@ # Dynamic API | ||
## Even Emitter | ||
DynamicApi is an emitter, it does not emit anything by itself but you can use it to communicate to other parts of your app what is going on in your dynamics. | ||
```js | ||
import { Dynamic } from '@universal-packages/dynamic-api' | ||
@Dynamic('calculate') | ||
export default class CalculateDynamic { | ||
public async perform(payload, dynamicApi) { | ||
dynamicApi.emit('event', 'A calculation was done') | ||
if(payload.fast) { | ||
return 'I did it fast' | ||
} else { | ||
return 'I was slow' | ||
} | ||
} | ||
} | ||
``` | ||
## Typescript | ||
@@ -166,0 +186,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
26344
256
216