Unsubscribe from resliceCursorWidget event

Hello!

If I am using the vtk.js example and then I don’t need the initial launched image anymore, so I want to upload new image into this example and I want to ask if somehow possible to unsubscribe from existing event widgetInstance.onInteractionEvent() and then create a new one for new image?

Or maybe there are better ways to load a new image into this structure, given that I would like to completely get rid of the old events?

Event itself:

v.widgetInstance.onInteractionEvent(
  ({ computeFocalPointOffset, canUpdateFocalPoint }) => {
    const activeViewType = widget
      .getWidgetState()
      .getActiveViewType();
    const keepFocalPointPosition =
      activeViewType !== viewType && canUpdateFocalPoint;
    updateReslice({
      viewType,
      reslice,
      actor: obj.resliceActor,
      renderer: obj.renderer,
      resetFocalPoint: false,
      keepFocalPointPosition,
      computeFocalPointOffset,
      sphereSources: obj.sphereSources,
      slider: obj.slider,
    });
  }
);

you can unsubscribe to events as such.

const s = v.widgetInstance.onInteractionEvent(...);
s.unsubscribe();
1 Like