{"id":1046,"url":"https://github.com/ladeiko/OneWaySynchronizer","last_synced_at":"2025-07-30T20:31:03.338Z","repository":{"id":62449601,"uuid":"140424781","full_name":"ladeiko/OneWaySynchronizer","owner":"ladeiko","description":"The simplest abstraction to synchronize local data with remote source. For iOS, wirtten in swift.","archived":false,"fork":false,"pushed_at":"2018-12-02T10:25:21.000Z","size":29,"stargazers_count":9,"open_issues_count":0,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-11-18T04:51:58.096Z","etag":null,"topics":["data-synchronization","ios","swift"],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ladeiko.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-07-10T11:54:25.000Z","updated_at":"2023-11-25T08:28:05.000Z","dependencies_parsed_at":"2022-11-01T23:46:49.111Z","dependency_job_id":null,"html_url":"https://github.com/ladeiko/OneWaySynchronizer","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ladeiko%2FOneWaySynchronizer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ladeiko%2FOneWaySynchronizer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ladeiko%2FOneWaySynchronizer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ladeiko%2FOneWaySynchronizer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ladeiko","download_url":"https://codeload.github.com/ladeiko/OneWaySynchronizer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228179152,"owners_count":17881137,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["data-synchronization","ios","swift"],"created_at":"2024-01-05T20:15:37.776Z","updated_at":"2024-12-04T19:32:44.181Z","avatar_url":"https://github.com/ladeiko.png","language":"Swift","readme":"[![Build Status](https://travis-ci.org/ladeiko/OneWaySynchronizer.svg?branch=master)](https://travis-ci.org/ladeiko/OneWaySynchronizer)\n\n# Purpose\n\nThe simplest abstraction to synchronize local data with remote source. For iOS, written in swift.\n\n## Overview\n\nMany 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.\r\n\n## Installation\r\n\n### Cocoapods\r\n\n```ruby\r\npod \"OneWaySynchronizer\"\r\n```\n\n### Manually\n\nClone repository and add files from ```Source``` folder to project.\n\n## Usage\n\nFor detailed example see [Demo](Demo) folder.\n\n## OneWaySynchronizer\n\n### Syncrhonization flow\n\n```\n   sync()\n      ↓\n   post OneWaySynchronizerDidChangeSyncStatusNotification\n      ↓\n   [called at the beginning of synchronization process]\n   owsSyncBegin\n      ↓\n   [return list of items from remote source, for example, from server]\n   owsFetchSourceList\n      ↓       ↓\n  ┌─\u003c err     ok\n  │           ↓\n  │ [return unique keys of locally existing items]\n  │  owsGetLocalKeys \n  │   ↓       ↓\n  ├─\u003c err     ok\n  │           ↓\n  │ [remove local items, because their keys were not found in source list]\n  │  owsRemoveLocalItems \n  │   ↓       ↓\n  ├─\u003c err     ok\n  │           ↓\n  │ [define if synchronizer should update already existing item]\n  │  owsShouldUpdateItem \n  │   ↓       ↓\n  ├─\u003c err     ok\n  │           ↓\n  │ [here you can reorder, filter items for next download operations]\n  │  owsPrepareDownload \n  │   ↓       ↓ \n  ├─\u003c err     ok\n  │           ↓\n  │ [download preview of item if necessary]\n  │  owsDownloadItemPreview \u003c───────────────────────────┐\n  │   ↓       ↓                                         │\n  ├─\u003c err     ok \u003e── concurrent loop for all previews ──┘\n  │           ↓\n  │ [download main content of item if necessary]\n  │  owsDownloadItem \u003c─────────────────────────────────┐\n  │   ↓       ↓                                        │\n  ├─\u003c err     ok \u003e── concurrent loop for all previews ─┘\n  │           ↓\n  │  [called after synchronization process]\n  └\u003e owsSyncEnd \n      ↓\n   sync completions\n      ↓ \n   post OneWaySynchronizerDidChangeSyncStatusNotification\n\n```\n\n### Methods\n\n* ```func sync(completion: @escaping OwsSyncCompletion = { _ in })```\n\nStarts 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.\n\n* ```func cancel()``` \n\nCancels currently running synchonization. If no any synchronization is running, then does nothing.\n\n### Options\n* ```concurrency``` - number of concurrent tasks while downloading. 0 - means auto. Default is 0.\n* ```downloadPreview``` - if true, then synchonizer should call method for preview downloading. Default is false.\n* ```downloadContent``` - if true, then synchonizer should call method for content downloading. Default is true.\n* ```stopOnError``` - if true, then sync will stop as soon as possible after first error. Default is true.\n\r\n## Changes\n\nSee [CHANGELOG](CHANGELOG.md)\n\r\n## License\r\n\r\nMIT. See [LICENSE](LICENSE)\r\n\r\n## Author\n\nSiarhei Ladzeika \u003csergey.ladeiko@gmail.com\u003e\n\n","funding_links":[],"categories":["Data Structures / Algorithms"],"sub_categories":["Getting Started","Linter"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fladeiko%2FOneWaySynchronizer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fladeiko%2FOneWaySynchronizer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fladeiko%2FOneWaySynchronizer/lists"}