INotifyHandler.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-License-Identifier: AGPL-3.0-or-later
  5. */
  6. namespace OCP\Files\Notify;
  7. /**
  8. * Provides access to detected changes in the storage by either actively listening
  9. * or getting the list of changes that happened in the background
  10. *
  11. * @since 12.0.0
  12. */
  13. interface INotifyHandler {
  14. /**
  15. * Start listening for update notifications
  16. *
  17. * The provided callback will be called for every incoming notification with the following parameters
  18. * - IChange|IRenameChange $change
  19. *
  20. * Note that this call is blocking and will not exit on it's own, to stop listening for notifications return `false` from the callback
  21. *
  22. * @param callable $callback
  23. *
  24. * @since 12.0.0
  25. */
  26. public function listen(callable $callback);
  27. /**
  28. * Get all changes detected since the start of the notify process or the last call to getChanges
  29. *
  30. * @return IChange[]
  31. *
  32. * @since 12.0.0
  33. */
  34. public function getChanges();
  35. /**
  36. * Stop listening for changes
  37. *
  38. * Note that any pending changes will be discarded
  39. *
  40. * @since 12.0.0
  41. */
  42. public function stop();
  43. }