Popularity
0.7
Stable
Activity
0.0
Stable
9
4
2

Programming language: Swift
License: MIT License
Latest version: v1.1.1

OneWaySynchronizer alternatives and similar libraries

Based on the "Data Structures / Algorithms" category.
Alternatively, view OneWaySynchronizer alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of OneWaySynchronizer or a related project?

Add another 'Data Structures / Algorithms' Library

README

Build Status

Purpose

The simplest abstraction to synchronize local data with remote source. For iOS, written in swift.

Overview

Many applications uses remote servers as sources for some data rendered later to user. Synchronization process is used to fetch data from remote server and store them locally. This operation consists of some standard stages: fetch, compare, diff, download new, etc... This module was created to simplify synchronization process by implementing all logic inside with interaction via protocol with external 'so-called' processor. All you need, just implement all requied async methods. All items should be unique and must have string unique keys. Synchronizer does not define order of items, it is responsibility of programmer. Demo example, fills order from server response and then sort items according to it.

Installation

Cocoapods

pod "OneWaySynchronizer"

Manually

Clone repository and add files from Source folder to project.

Usage

For detailed example see [Demo](Demo) folder.

OneWaySynchronizer

Syncrhonization flow

   sync()
      โ†“
   post OneWaySynchronizerDidChangeSyncStatusNotification
      โ†“
   [called at the beginning of synchronization process]
   owsSyncBegin
      โ†“
   [return list of items from remote source, for example, from server]
   owsFetchSourceList
      โ†“       โ†“
  โ”Œโ”€< err     ok
  โ”‚           โ†“
  โ”‚ [return unique keys of locally existing items]
  โ”‚  owsGetLocalKeys 
  โ”‚   โ†“       โ†“
  โ”œโ”€< err     ok
  โ”‚           โ†“
  โ”‚ [remove local items, because their keys were not found in source list]
  โ”‚  owsRemoveLocalItems 
  โ”‚   โ†“       โ†“
  โ”œโ”€< err     ok
  โ”‚           โ†“
  โ”‚ [define if synchronizer should update already existing item]
  โ”‚  owsShouldUpdateItem 
  โ”‚   โ†“       โ†“
  โ”œโ”€< err     ok
  โ”‚           โ†“
  โ”‚ [here you can reorder, filter items for next download operations]
  โ”‚  owsPrepareDownload 
  โ”‚   โ†“       โ†“ 
  โ”œโ”€< err     ok
  โ”‚           โ†“
  โ”‚ [download preview of item if necessary]
  โ”‚  owsDownloadItemPreview <โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
  โ”‚   โ†“       โ†“                                         โ”‚
  โ”œโ”€< err     ok >โ”€โ”€ concurrent loop for all previews โ”€โ”€โ”˜
  โ”‚           โ†“
  โ”‚ [download main content of item if necessary]
  โ”‚  owsDownloadItem <โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
  โ”‚   โ†“       โ†“                                        โ”‚
  โ”œโ”€< err     ok >โ”€โ”€ concurrent loop for all previews โ”€โ”˜
  โ”‚           โ†“
  โ”‚  [called after synchronization process]
  โ””> owsSyncEnd 
      โ†“
   sync completions
      โ†“ 
   post OneWaySynchronizerDidChangeSyncStatusNotification

Methods

  • func sync(completion: @escaping OwsSyncCompletion = { _ in })

Starts synchronization process. If another process is in progress, then after its completion new synchronization will be initiated, both completion callbacks will be called at the end of the last synchronization.

  • func cancel()

Cancels currently running synchonization. If no any synchronization is running, then does nothing.

Options

  • concurrency - number of concurrent tasks while downloading. 0 - means auto. Default is 0.
  • downloadPreview - if true, then synchonizer should call method for preview downloading. Default is false.
  • downloadContent - if true, then synchonizer should call method for content downloading. Default is true.
  • stopOnError - if true, then sync will stop as soon as possible after first error. Default is true.

Changes

See [CHANGELOG](CHANGELOG.md)

License

MIT. See [LICENSE](LICENSE)

Author

Siarhei Ladzeika [email protected]


*Note that all licence references and agreements mentioned in the OneWaySynchronizer README section above are relevant to that project's source code only.