import { Component, Input, Output, EventEmitter } from '@angular/core';

@Component({
    selector: 'app-load-more',
    templateUrl: 'app-load-more.html',
    styleUrls: ['app-load-more.scss']
})
export class AppLoadMore {
    /**
     * 是否为嵌入视图
     *
     * @type {boolean}
     * @memberof AppLoadMore
     */
    @Input()
    isEmbeddedView: boolean = false;
    /**
     * 加载模式
     *
     * @type {(1 | 2)}
     * @memberof AppLoadMore
     */
    @Input()
    loadMode: 1 | 2 = 1;
    /**
     * 是否还有更多数据
     *
     * @type {boolean}
     * @memberof AppLoadMore
     */
    @Input()
    isInfinite: boolean = true;
    /**
     * 是否正在加载
     *
     * @type {boolean}
     * @memberof AppLoadMore
     */
    @Input()
    isSendingRequest: boolean = false;
    /**
     * 加载更多
     *
     * @type {EventEmitter<any>}
     * @memberof AppLoadMore
     */
    @Output()
    loadMore: EventEmitter<any> = new EventEmitter();

    /**
     * 触发加载更多
     *
     * @param {*} event
     * @memberof AppLoadMore
     */
    public onMore(event: any): void {
        this.loadMore.emit(event);
    }

}