Skip to content

Make the Lifecycle constructor parameter in DefaultComponentContext optional (re-apply #1049) - #1068

Merged
arkivanov merged 1 commit into
masterfrom
reapply-1049
Nov 9, 2026
Merged

arkivanov merged 1 commit into
masterfrom
reapply-1049

Conversation

@arkivanov-bot

@arkivanov-bot arkivanov-bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator

Re-applies #1049 after #1065 (the temporary revert for the 3.6.0 release).

Restores the empty DefaultComponentContext() constructor (backed by a default LifecycleRegistry), updates the binary-compatibility API dumps, removes the sample PreviewComponentContext helper, and points the sample preview components at DefaultComponentContext() again.

Requested in #1065 (comment).

Summary by CodeRabbit

  • New Features
    • Added a no-argument constructor for DefaultComponentContext, making it simpler to create a context with a default lifecycle.
  • Refactor
    • Updated sample preview components to create their own default contexts rather than sharing one.

This reverts commit 86d67eb, reversing
changes made to 70498dd.

Co-authored-by: Arkadii Ivanov <26204457+arkivanov@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

DefaultComponentContext now has a public no-argument constructor. Preview components use separate instances of this constructor instead of a shared preview context.

Changes: Default preview contexts

Layer / File(s) Summary
Add the no-argument constructor
decompose/src/commonMain/kotlin/com/arkivanov/decompose/DefaultComponentContext.kt, decompose/api/android/decompose.api, decompose/api/jvm/decompose.api
The constructor creates a LifecycleRegistry and delegates with null state keeper, instance keeper, and back handler. Android and JVM API declarations include the constructor.
Use separate contexts in previews
sample/shared/shared/src/commonMain/kotlin/com/arkivanov/sample/shared/PreviewComponentContext.kt, sample/shared/shared/src/commonMain/kotlin/com/arkivanov/sample/shared/counters/PreviewCountersComponent.kt, sample/shared/shared/src/commonMain/kotlin/com/arkivanov/sample/shared/multipane/PreviewMultiPaneComponent.kt, sample/shared/shared/src/commonMain/kotlin/com/arkivanov/sample/shared/root/PreviewRootComponent.kt
The preview components delegate to newly constructed DefaultComponentContext instances. The shared PreviewComponentContext object is removed.

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Feature

Possibly related PRs

Suggested reviewers: arkivanov

Merge Risk: Minimal · up to 25b59

The constructor restores the preview context setup, with separate instances for previews. No merge-blocking risk was identified.

Pre-merge checks: Passed 5

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title describes the main API change: callers can construct DefaultComponentContext without providing a Lifecycle.
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 4 files. (2 skipped: 2 unsupported.)

Finishing Touches

Generate docstrings

  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e2fc91ba-dbde-4a00-902c-5eedce98cc5e
Commits

Reviewing files that changed from the base of the PR and between a9be46a and 25b5934.

Files selected for processing: 7

  • decompose/api/android/decompose.api
  • decompose/api/jvm/decompose.api
  • decompose/src/commonMain/kotlin/com/arkivanov/decompose/DefaultComponentContext.kt
  • sample/shared/shared/src/commonMain/kotlin/com/arkivanov/sample/shared/PreviewComponentContext.kt
  • sample/shared/shared/src/commonMain/kotlin/com/arkivanov/sample/shared/counters/PreviewCountersComponent.kt
  • sample/shared/shared/src/commonMain/kotlin/com/arkivanov/sample/shared/multipane/PreviewMultiPaneComponent.kt
  • sample/shared/shared/src/commonMain/kotlin/com/arkivanov/sample/shared/root/PreviewRootComponent.kt
Files with no reviewable changes: 1

  • sample/shared/shared/src/commonMain/kotlin/com/arkivanov/sample/shared/PreviewComponentContext.kt

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

@arkivanov
arkivanov merged commit bb4a6a3 into master Nov 9, 2026
3 checks passed
@arkivanov
arkivanov deleted the reapply-1049 branch November 9, 2026 21:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants