@@ -2,9 +2,9 @@ package rs.wordpress.cache.kotlin
22
33import kotlinx.coroutines.asCoroutineDispatcher
44import kotlinx.coroutines.withContext
5- import uniffi.wp_api .DatabaseDelegate
6- import uniffi.wp_api .UpdateHook
7- import uniffi.wp_api .WpApiCache
5+ import uniffi.wp_mobile_cache .DatabaseDelegate
6+ import uniffi.wp_mobile_cache .UpdateHook
7+ import uniffi.wp_mobile_cache .WpApiCache
88import java.nio.file.Path
99import java.util.concurrent.Executors
1010
@@ -13,6 +13,7 @@ class WordPressApiCacheLoggingDelegate : DatabaseDelegate {
1313 println (" Received update: $updateHook " )
1414 }
1515}
16+
1617class WordPressApiCacheDelegate (
1718 private val callback : (updateHook: UpdateHook ) -> Unit
1819) : DatabaseDelegate {
@@ -31,7 +32,10 @@ class WordPressApiCache {
3132 constructor (delegate: WordPressApiCacheDelegate ? = null ) : this (" :memory:" , delegate)
3233
3334 // Creates a new cache at the specified file system URL
34- constructor (path: Path , delegate: WordPressApiCacheDelegate ? = null ) : this (path.toString(), delegate)
35+ constructor (path: Path , delegate: WordPressApiCacheDelegate ? = null ) : this (
36+ path.toString(),
37+ delegate
38+ )
3539
3640 // Creates a new cache at the specified path
3741 constructor (string: String , delegate: WordPressApiCacheDelegate ? = null ) {
@@ -42,6 +46,7 @@ class WordPressApiCache {
4246 suspend fun performMigrations (): Int = withContext(internalDispatcher) {
4347 cache.performMigrations().toInt()
4448 }
49+
4550 fun startListeningForUpdates () {
4651 if (this .delegate != null ) {
4752 this .cache.startListeningForUpdates(this .delegate)
0 commit comments