Advertisement
musclesonvacation

Inversify Issue resolving Concreate Implementation

Feb 3rd, 2019
320
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { ITransfer } from '../Interfaces/itransfer'
  2. import { injectable } from "inversify";
  3. import "reflect-metadata"
  4.  
  5. export interface ITransfer {
  6.     amount: number
  7.     global_index:number
  8.     toHMSET():string[]
  9. }
  10.  
  11. @injectable()
  12. export class ConreteTransfer implements ITransfer {
  13.  
  14.     private amount:number
  15.     private global_index:number
  16.     public toHMSET() : string[] {
  17.         return ['hmset', `transfer:${this.global_index}`, 'amount', `${this.amount}`]
  18.     }
  19. }
  20.  
  21. export const containerModules = new ContainerModule((bind) => {
  22.     bind<ITransfer>(TYPES.Transfer).to(ConcreteTransfer)
  23. })
  24.  
  25.  
  26. @injectable()
  27. export class example {
  28. public RecordIncomingTransfers(transfers:Array<ITransfer>) : void {
  29.             let commands:string[][] = new Array<Array<string>>()
  30.             for (var i = transfers.length - 1; i >= 0; i--) {
  31.                 commands.push(transfers[i].toHMSET())   //TypeError: transfers[i].toHMSET is not a function
  32.             }
  33.             console.log(commands)
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement