projects/i-components/src/lib/services/drag-drop.service.ts
Service to transfer data when executing a drag and drop action in the ListBox.
Properties |
|
Methods |
Accessors |
notifyDataTransfer | ||||||
notifyDataTransfer(value: any)
|
||||||
Notify theres is new data to transfer
Parameters :
Returns :
void
|
Public currentDragging |
Type : DraggableDirective
|
Current draggable being dragged |
Private dataTransfer |
Type : Subject<any>
|
Default value : new Subject<any>()
|
Subject to handle data transfer when executing a drag and drop action. |
dataTransferObservable |
getdataTransferObservable()
|
Observable to get if theres is any data.
Returns :
Observable<any>
|
import { Injectable } from '@angular/core';
import { Observable, Subject } from 'rxjs';
import { DraggableDirective } from '../directives/draggable.directive';
/**
* Service to transfer data when executing a drag and drop action in the ListBox.
*
* @export
* @class DragDropService
*/
@Injectable({
providedIn: 'root',
})
export class DragDropService {
/**
* Current draggable being dragged
*
* @private
* @type {DraggableDirective}
* @memberof DragDropService
*/
public currentDragging: DraggableDirective;
/**
* Subject to handle data transfer when executing a drag and drop action.
*
* @private
* @type {Subject<any>}
* @memberof DragDropService
*/
private dataTransfer: Subject<any> = new Subject<any>();
/**
* Observable to get if theres is any data.
*
* @readonly
* @type {Observable<any>}
* @memberof DragDropService
*/
get dataTransferObservable(): Observable<any> {
return this.dataTransfer.asObservable();
}
/**
* Notify theres is new data to transfer
*
* @param {any} value
* @memberof DragDropService
*/
notifyDataTransfer(value: any): void {
this.dataTransfer.next(value);
}
}