Skip to content

Commit

Permalink
Accept a ZiplineHttpClient creating a TreehouseAppFactory
Browse files Browse the repository at this point in the history
The current OkHttpClient is what we ultimately want to provide,
but that forces us to create the OkHttpClient eagerly and we'd
rather do that lazily.
  • Loading branch information
squarejesse committed Nov 8, 2024
1 parent a1ce792 commit e9c2eab
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

New:
- Redwood publishes what's happening in bound content through the new `Content.State` type.
- Accept a `ZiplineHttpClient` in `TreehouseAppFactory` on Android.

Changed:
- Drop support for non-incremental layouts in `Row` and `Column`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import android.content.Context
import app.cash.redwood.leaks.LeakDetector
import app.cash.zipline.loader.LoaderEventListener
import app.cash.zipline.loader.ManifestVerifier
import app.cash.zipline.loader.ZiplineHttpClient
import app.cash.zipline.loader.asZiplineHttpClient
import kotlinx.coroutines.Dispatchers
import okhttp3.OkHttpClient
Expand All @@ -38,9 +39,36 @@ public fun TreehouseAppFactory(
concurrentDownloads: Int = 8,
stateStore: StateStore = MemoryStateStore(),
leakDetector: LeakDetector = LeakDetector.none(),
): TreehouseApp.Factory = TreehouseAppFactory(
context = context,
httpClient = httpClient.asZiplineHttpClient(),
manifestVerifier = manifestVerifier,
embeddedFileSystem = embeddedFileSystem,
embeddedDir = embeddedDir,
cacheName = cacheName,
cacheMaxSizeInBytes = cacheMaxSizeInBytes,
loaderEventListener = loaderEventListener,
concurrentDownloads = concurrentDownloads,
stateStore = stateStore,
leakDetector = leakDetector,
)

@Suppress("FunctionName")
public fun TreehouseAppFactory(
context: Context,
httpClient: ZiplineHttpClient,
manifestVerifier: ManifestVerifier,
embeddedFileSystem: FileSystem? = null,
embeddedDir: Path? = null,
cacheName: String = "zipline",
cacheMaxSizeInBytes: Long = 50L * 1024L * 1024L,
loaderEventListener: LoaderEventListener = LoaderEventListener.None,
concurrentDownloads: Int = 8,
stateStore: StateStore = MemoryStateStore(),
leakDetector: LeakDetector = LeakDetector.none(),
): TreehouseApp.Factory = RealTreehouseApp.Factory(
platform = AndroidTreehousePlatform(context),
httpClient = httpClient.asZiplineHttpClient(),
httpClient = httpClient,
frameClockFactory = AndroidChoreographerFrameClock.Factory(),
manifestVerifier = manifestVerifier,
embeddedFileSystem = embeddedFileSystem,
Expand Down

0 comments on commit e9c2eab

Please sign in to comment.