Search in sources :

Example 1 with TreeRefreshedEventPayload

use of org.eclipse.sirius.components.collaborative.trees.dto.TreeRefreshedEventPayload in project sirius-components by eclipse-sirius.

the class TreeEventProcessor method refresh.

@Override
public void refresh(ChangeDescription changeDescription) {
    if (this.shouldRefresh(changeDescription)) {
        long start = System.currentTimeMillis();
        Tree tree = this.refreshTree();
        this.currentTree.set(tree);
        if (this.sink.currentSubscriberCount() > 0) {
            EmitResult emitResult = this.sink.tryEmitNext(new TreeRefreshedEventPayload(changeDescription.getInput().getId(), tree));
            if (emitResult.isFailure()) {
                // $NON-NLS-1$
                String pattern = "An error has occurred while emitting a TreeRefreshedEventPayload: {}";
                this.logger.warn(pattern, emitResult);
            }
        }
        long end = System.currentTimeMillis();
        this.timer.record(end - start, TimeUnit.MILLISECONDS);
    }
}
Also used : TreeRefreshedEventPayload(org.eclipse.sirius.components.collaborative.trees.dto.TreeRefreshedEventPayload) Tree(org.eclipse.sirius.components.trees.Tree) EmitResult(reactor.core.publisher.Sinks.EmitResult)

Example 2 with TreeRefreshedEventPayload

use of org.eclipse.sirius.components.collaborative.trees.dto.TreeRefreshedEventPayload in project sirius-components by eclipse-sirius.

the class TreeEventProcessor method getOutputEvents.

@Override
public Flux<IPayload> getOutputEvents(IInput input) {
    var initialRefresh = Mono.fromCallable(() -> new TreeRefreshedEventPayload(input.getId(), this.currentTree.get()));
    var refreshEventFlux = Flux.concat(initialRefresh, this.sink.asFlux());
    // @formatter:off
    return Flux.merge(refreshEventFlux, this.subscriptionManager.getFlux(input));
// @formatter:on
}
Also used : TreeRefreshedEventPayload(org.eclipse.sirius.components.collaborative.trees.dto.TreeRefreshedEventPayload)

Aggregations

TreeRefreshedEventPayload (org.eclipse.sirius.components.collaborative.trees.dto.TreeRefreshedEventPayload)2 Tree (org.eclipse.sirius.components.trees.Tree)1 EmitResult (reactor.core.publisher.Sinks.EmitResult)1