/**
 * Copyright (c) 2016-2018 Dmitry Panyushkin
 * Available under MIT license
 */ import * as ko from "knockout" ; import { arraySlice , defineProperty } from "./common-functions" ; import { EventType } from "./knockout-decorators" ; export function defineEventProperty ( instance , key ) { const subscribable = new ko . subscribable < any [ ] > ( ) ; const event = function ( ) { const eventArgs = arraySlice ( arguments ) ; subscribable . notifySubscribers ( eventArgs ) ; } as any ; event . subscribe = function ( callback ) { return subscribable . subscribe ( function ( eventArgs ) { callback . apply ( null , eventArgs ) ; } ) ; } ; defineProperty ( instance , key , { value : event , } ) ; return event ; }