src/connector.ts
For a simple component, unsubscribing is as easy as connection.unsubscribe()
in ngOnDestroy()
If your components have lots of subscriptions, it can get tedious having to
unsubscribe from all of them, and you might forget. A common pattern is to create an RxJS Subscription
(maybe called destroy
), to use this.destroy.add(xxx.subscribe(...))
and to call destroy.unsubscribe()
once to clean up all of them. @ng-dnd/core
supports this pattern with by using the subscription
parameter on the
constructors. Simply:
import { Subscription } from 'rxjs';
// ...
destroy = new Subscription();
target = this.dnd.dropTarget({
// ...
}, this.destroy);
ngOnDestroy() { this.destroy.unsubscribe(); }
It is a good habit for avoiding leaked subscriptions, because .
Methods |
|
Public dragLayer | ||||||
dragLayer(subscription?: AddSubscription)
|
||||||
Type parameters :
|
||||||
This method creates a DragLayer object
Parameters :
Returns :
DragLayer<Item>
|
Public dragSource | ||||||||||||||||
dragSource(type: string | symbol | null, spec: DragSourceSpec<Item | DropResult>, subscription?: AddSubscription)
|
||||||||||||||||
Type parameters :
|
||||||||||||||||
This method creates a DragSource object. It represents a drag
source and its behaviour, and can be connected to a DOM element by
assigning it to the It is the corollary of The Only the drop targets registered for the same type will
react to the items produced by this drag source. If you want a dynamic
type, pass connection to.
Parameters :
Returns :
DragSource<Item, DropResult>
|
Public dropTarget | ||||||||||||
dropTarget(types: TypeOrTypeArray | null, spec: DropTargetSpec<Item | DropResult>, subscription?: AddSubscription)
|
||||||||||||
Type parameters :
|
||||||||||||
This drop target will only react to the items produced by the drag sources of the specified type or types. If you want a dynamic type, pass
Parameters :
Returns :
DropTarget<Item, DropResult>
|