nope/test/modules/ComplexModule.ts

70 lines
1.7 KiB
TypeScript
Raw Normal View History

2020-11-10 07:56:22 +00:00
import { exportMethod } from "../../lib/decorators/moduleDecorators";
import { InjectableNopeBaseModule } from "../../lib/module/BaseModule.injectable";
2020-11-05 17:02:01 +00:00
import { NopeObservable } from "../../lib/observables/nopeObservable";
import { IF01 } from "./IF01";
export interface IF00 {
// Test property
hello: "world";
2020-11-05 17:02:01 +00:00
}
export class ComplexModuleWithDecorators extends InjectableNopeBaseModule {
// @exportProperty({
// mode: ['publish'],
// topic: 'propWithInternalDefinition'
// })
public propWithInternalDefinition = new NopeObservable<IF00>();
2020-11-05 17:02:01 +00:00
/**
* Function description
*
* @param {IF00} a Description of Parameter a
* @param {IF01} [b] Description of Optional Parameter b
* @return {*} {Promise<IF01>}
* @memberof ComplexModuleWithDecorators
*/
// @exportMethod({})
async exportedMethod(a: IF00, b?: IF01): Promise<IF01> {
b.name = a.hello;
return b;
}
2020-11-05 17:02:01 +00:00
@exportMethod({})
async exportedMethodWithCallback(
a: number,
b: number,
operator: (a: number, b: number) => Promise<number>
): Promise<number> {
return await operator(a, b);
}
2020-11-10 07:56:22 +00:00
@exportMethod({})
async exportedMethodWithCallbackCallback(
a: number,
b: number,
operator: (
a: number,
b: number,
c: (a: string) => Promise<number>
) => Promise<number>
): Promise<number> {
return await operator(a, b);
}
2020-11-10 07:56:22 +00:00
async init() {
this.author = {
forename: "Martin",
mail: "m.karkowski@zema.de",
surename: "karkowski"
};
this.description = "A Complex Module for Testing.";
this.type = "helloworld";
this.version = {
date: new Date("05.11.2020"),
version: 1
};
2020-11-05 17:02:01 +00:00
await super.init();
}
}