import { Observable } from 'rxjs'; import { SimpleChanges } from '@angular/core'; import { IGoogleMapsEventData } from '../abstraction/events/i-google-maps-event-data'; import { GoogleMapsComponentBase } from '../abstraction/base/google-maps-component-base'; import { EmittingWrapper, Wrapper } from '../abstraction/types/abstraction'; import { GoogleMapsApiService } from './google-maps-api.service'; /** * Provides tools for automating the component <-> wrapper relationship. */ export declare class GoogleMapsComponentApiService { api: GoogleMapsApiService; /** * Creates an instance of GoogleMapsComponentApiService. * @param {GoogleMapsApiService} api The low-level tools of the framework. */ constructor(api: GoogleMapsApiService); /** * Creates and assigns observables for component outputs decorated with the `@Hook()`. Any existing values will be overwritten. * The generated observables are automatically hooked to events of the native object represented by the given wrapper. * This method should be called in the component's constructor. This way, when angular attempts to bind template events it * will pick up the generated observables. * * Event arguments are automatically transformed using the `EventDataTransformService`. * In case a component's events should be hooked to a wrapper different to the one it holds, you can pass the it in using the `wrapper` argument. * * Note: [02-04-2020 Shy Agam] The whole idea of this method is to generate the observables itself and assign it to the `@Output()` members * so angular could subscribe and unsubscribe automatically without the need for manually handling `OnInit` and `OnDestroy`. * Currently, angular uses `EventEmitter` objects as standard. However, going the angular way requires a mechamism that will trigger the * `emit()` method of the emitter. Wrapping it in a class that manages an observable and hooks the `emit()` method? Merging somehow the observable with * with the emitter stream? Too complex and seems unnecessary as events can work perfectly with (and rely on) RxJs observables. * In case angular's implementation changes, or a better solution comes up, this should be reevaluated. * * @param {GoogleMapsComponentBase} emittingComponent The component/directive emitting the events. Should decorate `@Output()` members with `@Hook()`. * Hooked members will be assigned with a new observable, overwriting any existing value. * * @param {EmittingWrapper} [wrapper=emittingComponent.wrapper] (Optional) The wrapper of the native object which defines the events. By default, events will be hooked to * the native object contained by `emittingComponent.wrapper`. Pass a value to this argument only if the emitting component is not the one containing the native object. * Example: Google Maps's data layer native object raises events that should be emitted by the individual feature directives. * @see `google-maps-feature.directive.ts` for more info. * * @param {((event: IGoogleMapsEventData) => boolean | Promise)} [shouldEmit] (Optional) A filter function that will determine if the a specific event should be emitted or not. */ hookAndSetEmitters(emittingComponent: GoogleMapsComponentBase, wrapper?: EmittingWrapper, shouldEmit?: (event: IGoogleMapsEventData) => boolean | Promise): void; /** * Creates an observable hooked to a native event of a wrapper object and automatically transforms its event data. * Subscribe and unsubscribe are both hooked. * * @param {EmittingWrapper} wrapper The wrapper for which the event should be hooked. * @param {string} eventName The library's (camelCase) name for the event. * @param {string} eventReference The native name of the event. * @param {EmittingWrapper} associatedWrapper (Optional) The wrapper of the native object which defines the events. By default, events will be hooked to * the native object contained by `wrapper`. Pass a value to this argument only if the emitting wrapper is not the one containing the native object. * Example: Google Maps's data layer native object raises events that should be emitted by the individual feature directives. * @see `google-maps-feature.directive.ts` for more info. * @param {((event: IGoogleMapsEventData) => boolean | Promise)} [shouldEmit] (Optional) A filter function that will determine if the a specific event should be emitted or not. * @returns {Observable} An observable hooked to the native event of the wrapper. */ createEventEmitter(wrapper: EmittingWrapper, eventName: string, eventReference: string, associatedWrapper?: EmittingWrapper, shouldEmit?: (event: IGoogleMapsEventData) => boolean | Promise): Observable; /** * Goes through all changes presented by an `ngOnChanges()` call and, if wrapper has a matching setter method, delegates them to the setter on the wrapper. * Expects wrapper setter methods name to conform to the format of `setProperty` (`set` prefix, followed by a CamelCase component property name). * * @param {SimpleChanges} changes The changes object as received from the call to `ngOnChanges()` * @param {Wrapper} wrapper The wrapper to delegate changes to. */ delegateInputChangesToNativeObject(changes: SimpleChanges, wrapper: Wrapper): void; }