This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// normal aproach | |
public doStuff () { | |
this.instanceDialogRef = this.mdDialogInstance.open(YourDialogComponent) | |
... | |
} | |
// advice aproach | |
@ShowDialog(YourDialogComponent) | |
public doStuff () { | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var GameScene = require("../common/GameScene"); | |
var GameControls = require("../common/GameControls"); | |
var Player = require("./Player"); | |
var Wall = require("./Wall"); | |
window.scene1 = new GameScene("#sampleScene"); | |
var player = new Player({x: 35, y: 220}); | |
var leftBox = new Wall({x: 0, y: 0}, {x: 0, y: 500}); | |
var bottomBox = new Wall({x: 0, y: 500}, {x: 500, y: 500}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { AdvicePool, adviceMetadata, adviceParam, IMetadata } from 'kaop-ts' | |
import { Service } from './somewhere' | |
import { ICommonModel } from './somewhere' | |
export class PersistanceAdvices extends AdvicePool { | |
static read (@adviceMetadata meta: IMetadata, @adviceParam(0) model: ICommonModel) { | |
Service.get(model.url) | |
.then(data => meta.args.push(data)) | |
.then(this.next) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { beforeMethod } from 'kaop-ts' | |
import { PersistanceAdvices } from './persistance-advices' | |
import { FlowAdvices } from './flow-advices' | |
import { OrderModel } from './order-model' | |
class View { | |
@beforeMethod(PersistanceAdvices.read, OrderModel) | |
@beforeMethod(FlowAdvices.validate) | |
update (data?) { ... } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class Registry extends AdvicePool { | |
static log (@adviceMetadata meta: IMetadata) { | |
meta.args // Arguments to be received by decorated method | |
meta.propertyKey // Name of the decorated method as string | |
meta.scope // Instance or the context of the call stack | |
meta.rawMethod // Original method (contains metadata) | |
meta.target // Class definition | |
meta.result // The returned value by the method | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { AdvicePool, adviceMetadata, IMetadata } from 'kaop-ts' | |
import { Covfefe } from './covfefe-components' | |
export class Advices extends AdvicePool { | |
static blameRussia (@adviceMetadata meta: IMetadata) { | |
if(meta.exception) { | |
meta.result = <Covfefe/> | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { AdvicePool, adviceMetadata, IMetadata } from 'kaop-ts' | |
export class Advices extends AdvicePool { | |
static blameCovfefe (@adviceMetadata meta: IMetadata) { | |
meta.exception.message += " despite the constant negative press covfefe" | |
} | |
static throwOnError (@adviceMetadata meta: IMetadata) { | |
if(meta.exception) { | |
throw meta.exception |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as React from "react"; | |
import Sidebar from "../Sidebar/Sidebar.main"; | |
import Content from "../Content/Content.main"; | |
import { Advices } from "../../advices/Advices" | |
import { onException, afterMethod } from "kaop-ts" | |
export default class Root extends React.Component<null, null> { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as React from "react"; | |
import Sidebar from "../Sidebar/Sidebar.main"; | |
import Content from "../Content/Content.main"; | |
import { Advices } from "../../advices/Advices" | |
import { onException, afterMethod } from "kaop-ts" | |
export default class Root extends React.Component<null, null> { | |
@onException(Advices.blameCovfefe) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Controller = Class({ | |
constructor: function(app){ | |
app.get('/', this.home); | |
app.get('/login', this.login); | |
app.use(this.notFound); | |
}, | |
login: [function(req, res){ | |
//what ever | |
}, "log"], | |
home: [function(req, res){ |