This file contains hidden or 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
class Data { | |
@cancelPrevious() | |
getReportData(data: IReportParams): IReportData { | |
// some code | |
} | |
} |
This file contains hidden or 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
class WidgetProvider { | |
@after<WidgetProvider, Widget>({ | |
func: () => { | |
console.log('widget created') | |
} | |
}) | |
createWidget(name: string): Widget { | |
// some code | |
} |
This file contains hidden or 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
package oogaday.commons.enums | |
enum class StatusCode(val code: Int) { | |
Continue(100), | |
SwitchingProtocols(101), | |
Processing(102), | |
OK(200), | |
Created(201), | |
Accepted(202), |
This file contains hidden or 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 interface ISuccessError { | |
success: boolean; | |
result?: any; | |
error?: any; | |
} | |
type PromFucn = (...args: any[]) => Promise<any>; | |
promiseAllConcurrent(promFuncs: PromFucn[], | |
concurrent: number = 1): Promise<ISuccessError[]> { |
This file contains hidden or 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
const MEMOIZED_VALUE_KEY = '_memoizedValue'; | |
export function memoize(expirationTimeMs: number = 60000) { | |
return (target: any, propertyName: string, descriptor: TypedPropertyDescriptor<any>) => { | |
if (descriptor.value != null) { | |
const originalMethod = descriptor.value; | |
const fn: any = function (...args: any[]) { | |
const key = MEMOIZED_VALUE_KEY + '_' + JSON.stringify(args); | |
if (!fn[key]) { |
This file contains hidden or 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 const DEFAULT_DEBOUNCE_MS = 500; | |
export function debounce(ms: number = DEFAULT_DEBOUNCE_MS): Function { | |
return function (target: any, propertyKey: string, descriptor: PropertyDescriptor): any { | |
return { | |
configurable: true, | |
enumerable: descriptor.enumerable, | |
get: function (): () => any { | |
Object.defineProperty(this, propertyKey, { | |
configurable: true, |
This file contains hidden or 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
static batchPromise(proms: (() => Promise<any>)[], batchSize: number): Promise<void> { | |
return this.chunck(proms, batchSize) | |
.reduce((step: Promise<any>, chunck) => { | |
return step.then(() => { | |
return Promise.all(chunck.map(fp => fp())); | |
}); | |
}, Promise.resolve()); | |
} | |
private static chunck<T>(array: T[], batchSize = 5): T[][] { |
This file contains hidden or 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
{ | |
"name": "Oogaday", | |
"version": "0.0.0", | |
"main": "index.js", | |
"author": "Vlad Ioffe", | |
"license": "MIT", | |
"scripts": { | |
"serve": "webpack-dev-server --config=webpack.dev.config.js" | |
}, | |
"devDependencies": { |
This file contains hidden or 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
for f in $(find `pwd` -name "*.js"); do | |
cp "$f" "${f%.js}.ts" | |
done |
This file contains hidden or 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
# Refactoring Directives to 1.5 Components | |
Below you will find guide on how to refactor your directives to components: | |
**Step 1 - Rename your files suffix:** | |
Components should have the suffix `.component.ts` while directives have the `.dir.ts suffix`. | |
`<file_name>.drv.ts` ==> `<file_name>.component.ts` | |
Note: all related files should be renamed as well (jade, less, spec etc.). | |
**Step 2 - Change the module initialization:** | |
In the relevant module change the initialization from directive to component. |