{"id":17717108,"url":"https://github.com/bellapplab/blbackgroundrealm","last_synced_at":"2025-03-31T12:20:51.930Z","repository":{"id":56902984,"uuid":"138560232","full_name":"BellAppLab/BLBackgroundRealm","owner":"BellAppLab","description":"a collection of handy classes and extensions that make it easier to work with RLMRealm in the background.","archived":false,"fork":false,"pushed_at":"2018-10-22T19:41:59.000Z","size":92,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-10-14T14:02:41.324Z","etag":null,"topics":["ios","macos","objective-c","osx","realm","tvos","watchos"],"latest_commit_sha":null,"homepage":"","language":"Objective-C","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/BellAppLab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-06-25T07:42:24.000Z","updated_at":"2020-10-16T09:02:11.000Z","dependencies_parsed_at":"2022-08-20T18:50:57.161Z","dependency_job_id":null,"html_url":"https://github.com/BellAppLab/BLBackgroundRealm","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BellAppLab%2FBLBackgroundRealm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BellAppLab%2FBLBackgroundRealm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BellAppLab%2FBLBackgroundRealm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BellAppLab%2FBLBackgroundRealm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BellAppLab","download_url":"https://codeload.github.com/BellAppLab/BLBackgroundRealm/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246465239,"owners_count":20781919,"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":["ios","macos","objective-c","osx","realm","tvos","watchos"],"created_at":"2024-10-25T14:10:10.187Z","updated_at":"2025-03-31T12:20:51.913Z","avatar_url":"https://github.com/BellAppLab.png","language":"Objective-C","readme":"# BLBackgroundRealm [![Version](https://img.shields.io/badge/Version-1.0.5-black.svg?style=flat)](#installation) [![License](https://img.shields.io/cocoapods/l/BLBackgroundRealm.svg?style=flat)](#license)\n\n[![Platforms](https://img.shields.io/badge/Platforms-iOS|tvOS|macOS|watchOS-brightgreen.svg?style=flat)](#installation)\n[![CocoaPods Compatible](https://img.shields.io/cocoapods/v/BLBackgroundRealm.svg?style=flat\u0026label=CocoaPods)](https://cocoapods.org/pods/BLBackgroundRealm)\n[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n[![Twitter](https://img.shields.io/badge/Twitter-@BellAppLab-blue.svg?style=flat)](http://twitter.com/BellAppLab)\n\n![BLBackgroundRealm](./Images/background_realm.png)\n\nBLBackgroundRealm is a collection of handy classes and extensions that make it easier to work with `RLMRealm` in the background.\n\nIt's main focus is to enhance existing `RLMRealm`s and Realm-based code bases with very little overhead and refactoring. \n\n**Note**: Although this module makes it more convenient to work with a `RLMRealm` in the background, it does **not** make  `RLMRealm`s nor its objects thread-safe. They should still be accessed only from within their appropriate thread.\n\n## Specs\n\n* Realm 3.0.0+\n* iOS 9+\n* tvOS 10+\n* watchOS 3+\n* macOS 10.10+\n\n### Swift\n\nFor the Swift counterpart, see [BackgroundRealm](https://github.com/BellAppLab/BackgroundRealm).\n\n## Writing to a Realm in the background\n\nCommiting write transactions in the background becomes as easy as:\n\n```objc\n[RLMRealm writeInBackgroundWithConfiguration:\u003c#(nonnull RLMRealmConfiguration *)#\u003e\n                                    andBlock:^(RLMRealm * _Nullable realm, BLBackgroundRealmError * _Nullable error) \n{\n    \u003c#code#\u003e\n}];\n```\n\nOptionally, you can set a default `backgroundConfiguration` that will be used in all write transactions in the background:\n\n```objc\nRLMRealmConfiguration *config = [[RLMRealmConfiguration alloc] init];\nconfig.fileURL = url;\n[RLMRealmConfiguration setBackgroundConfiguration:config];\n\n[RLMRealm writeInBackgroundWithBlock:^(RLMRealm * _Nullable realm, BLBackgroundRealmError * _Nullable error) {\n    \u003c#code#\u003e\n}];\n```\n\nFinally, you can easily move from any `Realm` instance to its background counterpart:\n\n```objc\nRLMRealm *realm = [RLMRealm defaultRealm];\n\n[realm writeInBackgroundWithBlock:^(RLMRealm * _Nullable realm, BLBackgroundRealmError * _Nullable error) {\n    \u003c#code#\u003e\n}];\n```\n\n## The `BackgroundRealm`\n\nBackground Realm exposes a `BLBackgroundRealm`  class, which basically:\n\n1. creates a private `NSThread` and `NSRunLoop` where a new background `RLMRealm` will be opened\n2. opens a `RLMRealm` in the private thread\n3. runs work in the background thread\n\nThis is particularly useful if you'd like to:\n\n- make computationally expensive changes to the `RLMRealm`\n- register for change notifications in the background, without necessarily triggering a UI update right away\n\n### Usage\n\n- Creating a `BLBackgroundRealm` using `[RLMConfiguration backgroundConfiguration]`:\n\n```objc\nBLBackgroundRealm *bgRealm = [BLBackgroundRealm backgroundRealmWithBlock:^(RLMRealm * _Nullable realm, BLBackgroundRealmError * _Nullable error) {\n    \u003c#code#\u003e\n}];\n```\n\n- Creating a `BLBackgroundRealm` using a custom configuration:\n\n```objc\n[BLBackgroundRealm backgroundRealmWithConfiguration:\u003c#(nonnull RLMRealmConfiguration *)#\u003e \n                                           andBlock:^(RLMRealm * _Nullable realm, BLBackgroundRealmError * _Nullable error) \n{\n    \u003c#code#\u003e\n}];\n```\n\n- Creating a `BLBackgroundRealm` using a file `NSURL`:\n\n```objc\n[BLBackgroundRealm backgroundRealmWithFileURL:\u003c#(nonnull NSURL *)#\u003e \n                                     andBlock:^(RLMRealm * _Nullable realm, BLBackgroundRealmError * _Nullable error) \n{\n    \u003c#code#\u003e\n}];\n```\n\n## Installation\n\n### Cocoapods\n\n```ruby\npod 'BLBackgroundRealm', '~\u003e 1.0'\n```\n\nThen `#import \u003cBLBackgroundRealm/BLBackgroundRealm.h\u003e` where needed.\n\n### Carthage\n\n```objc\ngithub \"BellAppLab/BLBackgroundRealm\" ~\u003e 1.0\n```\n\nThen `#import \u003cBLBackgroundRealm/BLBackgroundRealm.h\u003e` where needed.\n\n### Git Submodules\n\n```shell\ncd toYourProjectsFolder\ngit submodule add -b submodule --name BLBackgroundRealm https://github.com/BellAppLab/BLBackgroundRealm.git\n```\n\nThen drag the `BLBackgroundRealm` folder into your Xcode project.\n\n## Forks\n\nWhen forking this repo, make sure to download the Realm framework and add it manually to the project.\n\n- [Realm - Objective-C - v3.0.0](https://static.realm.io/downloads/objc/realm-objc-3.0.0.zip)\n- [Realm - Objective-C - latest](https://realm.io/docs/objc/latest/)\n\n## Author\n\nBell App Lab, apps@bellapplab.com\n\n### Contributing\n\nCheck [this out](./CONTRIBUTING.md).\n\n### Credits\n\n[Logo image](https://thenounproject.com/search/?q=background\u0026i=635453#) by [mikicon](https://thenounproject.com/mikicon) from [The Noun Project](https://thenounproject.com/)\n\n## License\n\nBackgroundRealm is available under the MIT license. See the LICENSE file for more info.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbellapplab%2Fblbackgroundrealm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbellapplab%2Fblbackgroundrealm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbellapplab%2Fblbackgroundrealm/lists"}