Expose a way to wait for outbound sync to be complete before closing a container/component
This is needed for scenarios like:
- An app wants to ask the user for confirmation on tab close if their data is not saved (similar to Office Online)
- An app that opens multiple .fluid files and allows the user to switch between them needs to know when it is safe to shut down a fluid canvas (container/component)
Ideally this would be an async method on IContainer/IComponent that the caller can await before calling container.close()/component.onClose().
@vladsud Are you planning this for March or beyond?
@tylerbutler, moved it to April
@vladsud Any update on this one?
@jogonzal , I looked around, and maybe we have what you need? :)
Today, at ContainerRuntime level, you can subscribe to "dirtyDocument" / "savedDocument" events that I'be built some time ago (which should work, but we need to verify that) to know if there are any outstanding changes in the document. There are two potential issues with this approach:
- It might be very noisy, and if that's the case, you likely do not want to know that document is dirty, you might be looking for "all ops that were submitted up to time A are sent", i.e. an API of the following type:
public Barrier(): Promise
- Host does not have good way to reaching out to container runtime. And container runtime has no easy way to propagate that info up as well (the separate of concerns here is due to a fact that runtimes come and go as new code proposals are made).
For # 2 the best solution is to have a component that exposes this data, such that host can request this component and can communicate with it directly.
I was thinking about exposing Barrier kind of functionality at container level, but the problem is - container has no knowledge of pending changes made at runtime level when offline. So that's definitely wrong direction.
Can you please glance at https://office.visualstudio.com/OC/_git/office-bohemia/pullrequest/451683 ?
@jogonzal, @sureshsitaula-msft, I'd appreciate some clarity if what we have today is enough. If not, why. #1876 needs to be addressed in some way, but if that's sufficient, we should close this issue. If not, please feel free to reopen.