1.1.2 • Published 6 years ago
@candywings/pure-mvc v1.1.2
pure MVC
how to install
npm i @candywings/pure-mvc@latest
About
Based on standard Model-View-Controller architecture with extended functionality in TypeScript.
Added functionalities.
- Mediator have
sleep():voidandwake():voidfunctions, which give ability to stop and start mediator from listening notifications dynamically. - Mediator have
subscribeToNotifications(...notificationNames: string[]):voidandunsubscribeToNotification(notificationName: string):voidfunctions, which give ability to dynamically subscribe and unsubscribe listening notifications.listenNotificationInterests: string[]now is agetternot afunction. - Now it's allowed to have same mediator-view pairs, so for every mediator instance unique id will be generated, which is available in mediator in
id: number | stringproperty. - Now mediator has
setMediatorId(id: number| string):voidfunction to set id manually to sync mediator with object inVOandgetMediatorId(): number | stringto get it; - Now
facade.retrieveMediator(mediatorName: string, id?: number| string):Mediatorfunction has optional second propertyid: number | string. It's for cases where you have multiple instances of same mediator-view pairs. UsingretrieveMediatorfunction without givingid: number | stringargument, it will return first mediator from mediators with given name. - Now
Facadehas methodshasMediatorWithName(mediatorName: string):boolean, which will check if there is at least one mediator with given name, and methodretrieveMediators(mediatorName:string): Mediator[], which will return all mediators with given name. - Now facade has new function
getMediatorsCount(mediatorName: string): numberwhich returns count of Mediator with same name. It's for cases, when you want to write you own logic based on Mediator count. - Mediator have
index:numberproperty which shows the index in the same name mediators' list. - Same notification can call multiple commands. Functions are added to remove commands from notification's call queue. To remove single command from call queue call
removeCommand(notificationName:string, command:SimpleCommand):voidon facade, and to remove all commands from notification's queue callremoveCommands(notificationName: string):voidon facade. - To register command to work once use
registerCommandOnce(notificationName, command):voidon facade. It will be called only once, then it will be removed from commands queue. - Added
Guardfor command, it can be used to make checks before command willexecute, it has reference toFacadetoo.Guardhasabstract approve(notificationName: string, ...args: any[]):boolean | Promise<boolean>function which must be overridden. Async usage ofapprovefunction is possible. - Added
addGuard(...guardClassRefs: Guard[]):void,Guardclasses (not their instances) need to be given as arguments. - Added
onAnyGuardApproved(notificationName: string, ...args: any[]):void,onAnyGuardDenied(notificationName, ...args: any[]):voidandonAllGuardsDenied(notificationName, ...args: any[]):voidfunctions for handling guards approving cases. - Command has protected method
prepare():void, which is provided to add guards. - Command execution is being done in following sequence,
prepare -> checkGuards -> execute || onAnyGuardDenied && onAllGuardDenied - MacroCommands now can add
exclusiveSubCommands, so if on of added subCommands is approved, others won't event checked. To addexclusiveSubCommandcalladdExclusiveSubCommand(command, ...guards). Note thatexclusiveSubCommand's check is checking subCommand's self guards too. Even if you've added duplicate guards, exclusiveSubCommand checker will check only unique guards. - Added
registerMediatorsandremoveMediatorsfunctions. - Mediator has new method
subscribeToNotificationnot to usesubscribeToNotificationswhen subcribing to one notification.
1.1.2
6 years ago
1.1.1
6 years ago
1.1.0
6 years ago
1.0.17
6 years ago
1.0.16
6 years ago
1.0.15
6 years ago
1.0.14
6 years ago
1.0.13
6 years ago
1.0.12
6 years ago
1.0.11
6 years ago
1.0.10
6 years ago
1.0.9
6 years ago
1.0.8
7 years ago
1.0.7
7 years ago
1.0.6
7 years ago
1.0.5
7 years ago
1.0.4
7 years ago
1.0.3
7 years ago
1.0.2
7 years ago
1.0.1
7 years ago
1.0.0
7 years ago