fix argvArg for observables

This commit is contained in:
Philipp Kunz 2016-12-18 20:58:37 +01:00
parent c6db092062
commit f8a122b777
3 changed files with 10 additions and 10 deletions

View File

@ -8,7 +8,7 @@ export interface ICommandPromiseObject {
}
export interface ITriggerObservableObject {
triggerName: string;
subject: Subject<void>;
subject: Subject<any>;
}
export declare class Smartcli {
argv: any;
@ -42,12 +42,12 @@ export declare class Smartcli {
/**
* adds a Trigger. Like addCommand(), but returns an subscribable observable
*/
addTrigger(triggerNameArg: string): Subject<void>;
addTrigger(triggerNameArg: string): Subject<any>;
/**
* execute trigger by name
* @param commandNameArg - the name of the command to trigger
*/
trigger(triggerName: string): Subject<void>;
trigger(triggerName: string): Subject<any>;
/**
* allows to specify help text to be printed above the rest of the help text
*/

View File

@ -64,7 +64,7 @@ class Smartcli {
subject: triggerSubject
});
this.addCommand(triggerNameArg).then(() => {
triggerSubject.next();
triggerSubject.next(this.argv);
});
return triggerSubject;
}
@ -76,7 +76,7 @@ class Smartcli {
let triggerSubject = this.allTriggerObservablesMap.find(triggerObservableObjectArg => {
return triggerObservableObjectArg.triggerName === triggerName;
}).subject;
triggerSubject.next();
triggerSubject.next(this.argv);
return triggerSubject;
}
/**
@ -130,4 +130,4 @@ class Smartcli {
}
}
exports.Smartcli = Smartcli;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRjbGkuY2xhc3Nlcy5zbWFydGNsaS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0Y2xpLmNsYXNzZXMuc21hcnRjbGkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLHVCQUFzQjtBQUN0QiwrQkFBOEI7QUFFOUIsOENBQTZDO0FBRTdDLGlCQUFpQjtBQUNqQiw2QkFBK0I7QUFhL0I7SUFrQkk7UUFWQTs7V0FFRztRQUNILDBCQUFxQixHQUFHLElBQUksZUFBUyxFQUF5QixDQUFBO1FB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LEtBQUssQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDO2dCQUMzQyxJQUFJLENBQUMsT0FBTyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsQ0FBQTtZQUMzQixDQUFDO1lBQUMsSUFBSSxDQUFDLENBQUM7Z0JBQ0osSUFBSSxDQUFDLE1BQU0sQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLENBQUE7WUFDMUIsQ0FBQztRQUNMLENBQUMsQ0FBQyxDQUFBO1FBQ04sTUFBTSxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUE7SUFDdkIsQ0FBQztJQUVEOztPQUVHO0lBQ0gsVUFBVTtRQUNOLElBQUksQ0FBQyxJQUFJLEdBQUcsSUFBSSxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUE7UUFDMUIsSUFBSSxDQUFDLFlBQVksQ0FBQyxPQUFPLEVBQUUsQ0FBQTtRQUMzQixNQUFNLENBQUE7SUFDVixDQUFDO0NBRUo7QUEvSUQsNEJBK0lDIn0=

View File

@ -14,7 +14,7 @@ export interface ICommandPromiseObject {
export interface ITriggerObservableObject {
triggerName: string
subject: Subject<void>
subject: Subject<any>
}
export class Smartcli {
@ -83,13 +83,13 @@ export class Smartcli {
* adds a Trigger. Like addCommand(), but returns an subscribable observable
*/
addTrigger(triggerNameArg: string) {
let triggerSubject = new Subject<void>()
let triggerSubject = new Subject<any>()
this.allTriggerObservablesMap.add({
triggerName: triggerNameArg,
subject: triggerSubject
})
this.addCommand(triggerNameArg).then(() => {
triggerSubject.next()
triggerSubject.next(this.argv)
})
return triggerSubject
}
@ -102,7 +102,7 @@ export class Smartcli {
let triggerSubject = this.allTriggerObservablesMap.find(triggerObservableObjectArg => {
return triggerObservableObjectArg.triggerName === triggerName
}).subject
triggerSubject.next()
triggerSubject.next(this.argv)
return triggerSubject
}