File

projects/netgrif-components-core/src/lib/task-content/services/task-event.service.ts

Description

Holds logic about the available operations on a Task object based on it's state.

Beware that it gets the Task from (@link TaskContentService) instance and thus the task might not be always initialized. If the task is not initialized this class cannot work properly.

Extends

TaskHandlingService

Index

Properties
Methods
Accessors

Constructor

constructor(_taskContentService: TaskContentService)
Parameters :
Name Type Optional
_taskContentService TaskContentService No

Methods

ngOnDestroy
ngOnDestroy()

Completes the stream

Returns : void
Public publishTaskEvent
publishTaskEvent(event: TaskEventNotification)

Emits a new TaskEventNotification into the notifications stream

Parameters :
Name Type Optional Description
event TaskEventNotification No

the event information that will be pushed into the stream

Returns : void
Protected isTaskPresent
isTaskPresent()
Inherited from TaskHandlingService
Returns : boolean

true if a {

Protected isTaskRelevant
isTaskRelevant(requestedTaskId: string)
Inherited from TaskHandlingService

Checks whether the current state of the TaskContentService and optionally if the SelectedCaseService, is still relevant to the task that was requested.

This method is useful if you use UnlimitedTaskContentService, or a similar implementation. It is possible for the currently "selected" task to change in-between a backend request was sent and the response was received. In that case the response is no longer relevant and should be discarded, otherwise an illegal task state could be achieved on frontend.

Parameters :
Name Type Optional Description
requestedTaskId string No

the stringId of the requested task

Returns : boolean

true if the requested task is still relevant to the state of the frontend. Returns false otherwise.

Properties

Protected _taskEventNotifications$
Type : Subject<TaskEventNotification>

Accessors

taskEventNotifications$
gettaskEventNotifications$()

Provides information about results of events executed on the managed Task

import {Injectable, OnDestroy} from '@angular/core';
import {TaskContentService} from './task-content.service';
import {TaskHandlingService} from '../../task/services/task-handling-service';
import {Observable, Subject} from 'rxjs';
import {TaskEventNotification} from '../model/task-event-notification';

/**
 * Holds logic about the available operations on a {@link Task} object based on it's state.
 *
 * Beware that it gets the Task from (@link TaskContentService) instance and thus the task might not be always initialized.
 * If the task is not initialized this class cannot work properly.
 */
@Injectable()
export class TaskEventService extends TaskHandlingService implements OnDestroy {

    protected _taskEventNotifications$: Subject<TaskEventNotification>;

    constructor(_taskContentService: TaskContentService) {
        super(_taskContentService);
        this._taskEventNotifications$ = new Subject<TaskEventNotification>();
    }

    /**
     * Completes the stream
     */
    ngOnDestroy(): void {
        this._taskEventNotifications$.complete();
    }

    /**
     * Provides information about results of events executed on the managed {@link Task}
     */
    public get taskEventNotifications$(): Observable<TaskEventNotification> {
        return this._taskEventNotifications$.asObservable();
    }

    /**
     * Emits a new {@link TaskEventNotification} into the notifications stream
     * @param event the event information that will be pushed into the stream
     */
    public publishTaskEvent(event: TaskEventNotification): void {
        this._taskEventNotifications$.next(event);
    }
}

result-matching ""

    No results matching ""