Fixing Template Generation

This commit is contained in:
Martin Karkowski 2020-09-01 17:48:07 +02:00
parent f59fb7a7e3
commit 878dce53d2
5 changed files with 14 additions and 33 deletions

1
.gitignore vendored
View File

@ -104,4 +104,3 @@ temp
# TernJS port file
.tern-port
config/
backend-api/

View File

@ -35,11 +35,11 @@ export async function generateClientTemplate(options: {
path: ['dispatcher'],
src: ['lib', 'dispatcher']
},
{
name: 'nopeObservable.ts',
path: ['observables'],
src: ['lib', 'observables']
},
// {
// name: 'nopeObservable.ts',
// path: ['observables'],
// src: ['lib', 'observables']
// },
{
name: 'nopeRemoteObservable.ts',
path: ['observables'],

View File

@ -1,32 +1,15 @@
import { Observable } from 'rxjs';
import { nopeDispatcher } from "../dispatcher/nopeDispatcher";
import { pipe } from "./nopeObservable";
export type pipe<T, K> = (scope: { [index: string]: any }, observable: Observable<T>) => Observable<K>
export class nopeRemoteObservable<T> {
protected _currentLocalValue: T;
export class nopeRemoteObservable<G, S = G> {
protected _pathes: {
get: string,
set: string,
subscribe: string,
}
/**
* Getter for the Current Value.
*/
public get currentLocalValue(): T {
return this._currentLocalValue;
}
/**
* Setter for the Current value.
*/
public set currentLocalValue(value: T) {
this.setRemoteValue(value).catch(e => {
// Catch the Error an rethrow it.
throw e;
});
}
/**
* Creates a Remote Dispatcher.
* @param _dispatcher
@ -46,14 +29,12 @@ export class nopeRemoteObservable<T> {
}
public async getRemoteValue() {
return await this._dispatcher.performCall<T>(this._pathes.get, [])
return await this._dispatcher.performCall<G>(this._pathes.get, [])
}
public async setRemoteValue(value: T) {
// Update the Local Value as Well
this._currentLocalValue = value;
public async setRemoteValue(value: S) {
// Perform an Update.
return await this._dispatcher.performCall<T>(this._pathes.set, [value]);
return await this._dispatcher.performCall<void>(this._pathes.set, [value]);
}
/**
@ -63,7 +44,7 @@ export class nopeRemoteObservable<T> {
*/
public async subscribe<K>(next: (data: K) => void, options: {
scope?: { [index: string]: any },
pipe?: pipe<T, K>
pipe?: pipe<G, K>
} = {}) {
return await this._dispatcher.performCall<() => void>(this._pathes.subscribe, [next, options]);
}

View File

@ -1,7 +1,7 @@
{
"dispatcher": {
"inputDir": "./test/*.ts",
"outputDir": "./backend-api",
"outputDir": "./resources/backend-api",
"pathToClientTemplate": "./lib/templates/clientInterface.handlebars",
"pathToInterfaceTemplate": "./lib/templates/backendInterface.handlebars",
"tsConfigFilePath": "./tsconfigBackend.json"

1
resources/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
backend-api