UNPKG

mvp-di

Version:

A simple DI package inspired by the MVP pattern. It can inject the presentation layer in React.js/React Native applications.

11 lines (8 loc) 444 B
import {Injectable} from "./Injectable"; export function viewProperty(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<any>): TypedPropertyDescriptor<any> { if (!descriptor || (typeof descriptor.value !== 'function')) { throw new TypeError(`Only methods can be decorated with @injectedProperty. ${propertyKey} is not a method!`); } Object.setPrototypeOf(target[propertyKey], Injectable); return descriptor; }