Commit 542eb35
Clément Le Provost
New offline features (#185)
* [offline] Support bootstrapping mirrored indices with local data
This feature allows initializing a local mirror from local data (typically, prepackaged resources) without having to wait for the first sync.
* [offline] Expose `hasOfflineData()` at the index level
* [offline] Add a `buildOffline(…)` method on `MirroredIndex`
This unconditionally creates or replaces the local mirror with the specified data, regardless of whether local data already exists or not for the index. (In contrast to `boostrap(…)`, which only does so if no data exists.)
* [offline] Support offline fallback for getting objects (WIP)
The `Index.getObjects(…)` methods are overridden by `MirroredIndex`, providing the same offline fallback mechanism as search.
NOTE: Only supported for `getObjects` so far; getting a single object will follow later.
* [offline] Fix race condition in instantiation of local index
It turns out that [lazy variables are not thread-safe](http://stackoverflow.com/a/29761777). We therefore have to synchronize initialization manually.
* [offline] Refactor recent features
- Remove `bootstrap(…)`: it is superseded by `buildOffline(…)`
- Use a dynamic property instead of a function for `hasOfflineData`
- Rename notifications from `bootstrapDid*` to `buildDid*`
- Update reference documentation
* [offline] Leverage `buildOffline` inside sync
This allows to send build notifications also for a sync.
* [offline] Add unit test for `MirroredIndex.buildOffline(…)`
* Fix compilation warnings
The `syncErrorKey` notification key is now deprecated in favor of `errorKey`.
* [offline] Add utilities to tag content origin as local or remote
* [offline] Add offline support to `MirroredIndex.getObject(…)`
* [offline] Fix ambiguous overload
* [refact] Use utilities to tag content origin
* Ooops
* [offline] Add test cases for `MirroredIndex.getObject[s]`
* [offline] Fix compilation of unit tests
Xcode or Cocoapods (not sure which one) has trouble dealing with two distinct modules both named “AlgoliaSearch”. We therefore rename the offline flavor to “AlgoliaSearchOffline”.
NOTE: This is **not** what we want clients of the library to be using, but since the module name is overridden by Cocoapods, and the scheme is not shared with Carthage, this should impact only the unit tests, not the users of the module.
* [refact] Add completion handler to `MirroredIndex.buildOffline(…)`
* [refact] Use dynamic property instead of function for `OfflineIndex.hasOfflineData`
* [offline] Add manual build capability to `OfflineIndex`
* Fix some inconsistencies
* [doc][offline] Update reference documentation
[ci skip]
* [doc][offline] Fix generation of reference documentation
Changing the module name had unintended side effects on the documentation. This should fix it.
* [refact][offline] Return an operation from manual build methods
* [offline] Assert that mirroring is on before testing local data
* [offline][doc] Update reference documentation
[ci skip]1 parent eaa9a50 commit 542eb35
File tree
14 files changed
+759
-109
lines changed- AlgoliaSearch.xcodeproj
- Source
- Offline
- Tests
- Offline
- tools
14 files changed
+759
-109
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
142 | | - | |
| 142 | + | |
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
148 | 148 | | |
149 | 149 | | |
| 150 | + | |
| 151 | + | |
150 | 152 | | |
151 | 153 | | |
152 | 154 | | |
| |||
215 | 217 | | |
216 | 218 | | |
217 | 219 | | |
218 | | - | |
| 220 | + | |
219 | 221 | | |
220 | 222 | | |
221 | 223 | | |
| |||
239 | 241 | | |
240 | 242 | | |
241 | 243 | | |
| 244 | + | |
| 245 | + | |
242 | 246 | | |
243 | 247 | | |
244 | 248 | | |
| |||
308 | 312 | | |
309 | 313 | | |
310 | 314 | | |
311 | | - | |
| 315 | + | |
312 | 316 | | |
313 | 317 | | |
314 | 318 | | |
| |||
345 | 349 | | |
346 | 350 | | |
347 | 351 | | |
348 | | - | |
| 352 | + | |
349 | 353 | | |
350 | 354 | | |
351 | 355 | | |
| |||
456 | 460 | | |
457 | 461 | | |
458 | 462 | | |
| 463 | + | |
| 464 | + | |
459 | 465 | | |
460 | 466 | | |
461 | 467 | | |
| |||
607 | 613 | | |
608 | 614 | | |
609 | 615 | | |
610 | | - | |
| 616 | + | |
611 | 617 | | |
612 | 618 | | |
613 | 619 | | |
| |||
790 | 796 | | |
791 | 797 | | |
792 | 798 | | |
| 799 | + | |
| 800 | + | |
793 | 801 | | |
794 | 802 | | |
795 | 803 | | |
| |||
1422 | 1430 | | |
1423 | 1431 | | |
1424 | 1432 | | |
1425 | | - | |
| 1433 | + | |
1426 | 1434 | | |
1427 | 1435 | | |
1428 | 1436 | | |
| |||
1444 | 1452 | | |
1445 | 1453 | | |
1446 | 1454 | | |
1447 | | - | |
| 1455 | + | |
1448 | 1456 | | |
1449 | 1457 | | |
1450 | 1458 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
146 | | - | |
147 | | - | |
| 146 | + | |
148 | 147 | | |
149 | 148 | | |
150 | 149 | | |
151 | 150 | | |
152 | 151 | | |
153 | | - | |
| 152 | + | |
| 153 | + | |
154 | 154 | | |
155 | 155 | | |
156 | 156 | | |
157 | 157 | | |
158 | | - | |
| 158 | + | |
159 | 159 | | |
160 | 160 | | |
161 | 161 | | |
| |||
170 | 170 | | |
171 | 171 | | |
172 | 172 | | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
| 173 | + | |
183 | 174 | | |
184 | 175 | | |
185 | 176 | | |
| |||
191 | 182 | | |
192 | 183 | | |
193 | 184 | | |
194 | | - | |
| 185 | + | |
195 | 186 | | |
196 | 187 | | |
197 | 188 | | |
198 | 189 | | |
199 | | - | |
| 190 | + | |
200 | 191 | | |
201 | 192 | | |
202 | | - | |
203 | 193 | | |
| 194 | + | |
204 | 195 | | |
205 | 196 | | |
206 | 197 | | |
| |||
0 commit comments