Class SyncRepository

    • Method Detail

      • doSync

         final Unit doSync(SyncParams params)

        Run the sync logic and update the user status if needed

        Parameters:
        params - parameters SyncParams for request
      • blockingSync

         final Unit blockingSync(SyncParams params)

        Run the sync logic and update the user status if needed This function blocks until the sync is done. It must never be called from the main/UI thread or it might throw a NetworkOnMainThreadException

        This function exposes the suspend function through a regular function that can be safely called from Java with Android minAPI 16

        Parameters:
        params - parameters SyncParams for request
      • nonBlockingSync

         final Unit nonBlockingSync(SyncParams params)

        Run the sync logic and update the user status if needed This function does not block until the sync is done. It can safely be called from the main thread.

        This function exposes the suspend function through a regular function that can be safely called from Java with Android minAPI 16

        Parameters:
        params - parameters SyncParams for request
      • shouldSyncFromFrequency

         final Boolean shouldSyncFromFrequency(Integer frequency, Date lastSyncDate)

        Determine whether we should sync based on the last sync date and the configured frequency

        We sync if:

        • There is no frequency configured or no sync date available

        • The last sync date is older than the frequency

        Parameters:
        frequency - as duration between sync in seconds
        lastSyncDate - as the last sync date
      • shouldSync

         final Boolean shouldSync(Boolean enabled, Integer frequency, Date lastSyncDate)

        Determine whether we should run sync or not

        Parameters:
        enabled - is sync is enabled
        frequency - as duration between sync in seconds
        lastSyncDate - as the last sync date