Skip to content

Conversation

harrytmthy
Copy link
Owner

Summary

This update introduces:

  • SafeBoxGlobalStateObserver for global state tracking (STARTING, WRITING, IDLE, CLOSED)
  • closeWhenIdle() method to ensure file is closed only when all pending writes have completed

This improves lifecycle safety in non-singleton environments (e.g. ViewModel-scoped SafeBox).

Implementation Details

  • Added a new STARTING state to differentiate the initial load vs uninitialized state (null).
  • SafeBoxBlobStore now tracks a MutableStateFlow write counter
  • SafeBox.closeWhenIdle() delegates safely using safeBoxScope.launch
  • Global observer holds and emits latest state on subscription

Closes part of #12 (will be completed in global state listener PR)

@harrytmthy harrytmthy self-assigned this Jun 1, 2025
@harrytmthy harrytmthy added the enhancement New feature or request label Jun 1, 2025
@harrytmthy harrytmthy merged commit 6cfa07e into main Jun 1, 2025
3 checks passed
@harrytmthy harrytmthy deleted the feat/add-safebox-global-state-observer branch June 1, 2025 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant