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
function enumerable(value) { | |
return function (target, propertyKey, descriptor) { | |
console.log('decorator - sets the enumeration part of the accessor'); | |
descriptor.enumerable = value; | |
}; | |
} | |
var Employee = /** @class */ (function () { | |
function Employee() { |
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
function enumerable(value: boolean) { | |
return function (target: any, propertyKey: string, descriptor: PropertyDescriptor) { | |
console.log('decorator - sets the enumeration part of the accessor'); | |
descriptor.enumerable = value; | |
}; | |
} | |
class Employee { | |
private _salary: number; |
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
// return the decorator function by accepting parameter index and decorator | |
var __param = (this && this.__param) || function (paramIndex, decorator) { | |
// function that returns decorator | |
return function (target, key) { decorator(target, key, paramIndex); } | |
}; | |
var Employee = /** @class */ (function () { | |
function Employee() { | |
} | |
Employee.prototype.greet = function (message) { |
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
function logParameter(target: Object, propertyName: string, index: number) { | |
// generate metadatakey for the respective method | |
// to hold the position of the decorated parameters | |
const metadataKey = `log_${propertyName}_parameters`; | |
if (Array.isArray(target[metadataKey])) { | |
target[metadataKey].push(index); | |
} | |
else { | |
target[metadataKey] = [index]; |
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 Employee = /** @class */ (function () { | |
function Employee() { | |
} | |
__decorate([ | |
logParameter | |
], Employee.prototype, "name"); | |
return Employee; | |
}()); | |
var emp = new Employee(); | |
emp.name = 'Mohan Ram'; // Set: name => Mohan Ram |
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
function logParameter(target: Object, propertyName: string) { | |
// property value | |
let _val = this[propertyName]; | |
// property getter method | |
const getter = () => { | |
console.log(`Get: ${propertyName} => ${_val}`); | |
return _val; | |
}; |
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
"use strict"; | |
var __decorate = (this && this.__decorate) || | |
function (decorators, target, key, desc) { | |
// function argument length | |
var c = arguments.length | |
/** | |
* manipulating the result | |
* if - only the array of decorators and target is passed | |
* then - it should be an class decorator |
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 function logMethod( | |
target: Object, | |
propertyName: string, | |
propertyDesciptor: PropertyDescriptor): PropertyDescriptor { | |
// target === Employee.prototype | |
// propertyName === "greet" | |
// propertyDesciptor === Object.getOwnPropertyDescriptor(Employee.prototype, "greet") | |
const method = propertyDesciptor.value; |
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
// dashboard.component.ts | |
import { ID } from '@datorama/akita'; | |
import { createStudent, StudentService, StudentQuery, Student } from './state/index'; | |
@Component({ | |
template: ` | |
<div class="container-fluid"> | |
... | |
<div class="row"> | |
<app-chart [studentsGraphData$]="studentQuery.studentsGraphData$"></app-chart> |
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
/** | |
* Below codes are from the type declaration of Akita | |
*/ | |
// An interface to represent objects | |
export interface HashMap<T> { | |
[id: string]: T; | |
} | |
/** |