I'm building a collaborative whiteboard app and I want to remove a fabric object from another user's canvas. I am using socket.io to send changes to other users and adding objects works fine, but there is a problem with removing. How can I do this without re-rendering the canvas, because I've set the background image to canvas and when i re-render the canvas the background image is not visible for some time.
Working code for adding object to canvas:
socket.current.on("object:added", (object) => {
isRendering.current = true;
fabric.util.enlivenObjects([JSON.parse(object)], (objects) => {
objects.forEach((o) => {
editor.canvas.add(o);
});
isRendering.current = false;
});
});
I want to make something like this, but to remove object from canvas.