Coder Social home page Coder Social logo

tomkad99 / decompose Goto Github PK

View Code? Open in Web Editor NEW

This project forked from arkivanov/decompose

0.0 0.0 0.0 192.24 MB

Kotlin Multiplatform lifecycle-aware business logic components (aka BLoCs) with routing (navigation) and pluggable UI (Jetpack Compose, SwiftUI, JS React, etc.)

Home Page: https://arkivanov.github.io/Decompose

License: Apache License 2.0

Kotlin 100.00%

decompose's Introduction



License Twitter URL


Decompose is a Kotlin Multiplatform library for breaking down your code into tree-structured lifecycle-aware business logic components (aka BLoC), with routing functionality and pluggable UI (Jetpack/Multiplatform Compose, Android Views, SwiftUI, Kotlin/React, etc.).

Please see the project website for documentation and APIs.

Should you have any questions or ideas - there is Discussions section. Also welcome to the Kotlin Slack channel - #decompose!

⚡⚡⚡ Where are all the stars, issues, discussions, pull requests, etc?

Having spent 5 years working on a variety of projects for Badoo/Bumble, I’m now off to another adventure. As part of that transition I was asked to transfer this repository to Badoo GitHub account.

Now I continue my work on this project as a copy.

There should be no breaking changes related to this transfer. Most of the external links should not be broken. The repository link is also the same: arkivanov/Decompose. Please file an issue in this repository, if you think something is broken or does not work properly.

Here is what is mostly affected by the transfer:

  • All the stars were transferred
  • All the issues and discussions were transferred as well. I will do all my best to fill the gap here.
  • All pull requests with all the comment history are also gone.

I will continue doing all my best for this project and for the community! Business as usual!

Additional resources:

Why Decompose?

  • Decompose breaks the code down into small and independent components and organizes them into trees. Each parent component is only aware of its immediate children.
  • Decompose draws clear boundaries between UI and non-UI code, which gives the following benefits:
    • Better separation of concerns
    • Pluggable platform-specific UI (Compose, SwiftUI, Kotlin/React, etc.)
    • Business logic code is testable with pure multiplatform unit tests
  • Navigation state is fully exposed - plug any UI you want, animate as you like using your favourite UI framework's API or use predefined API.
  • Navigation is a pure function from the old state to a new one - navigate without limits.
  • Proper dependency injection (DI) and inversion of control (IoC) via constructor, including but not limited to type-safe arguments.
  • Shared navigation logic
  • Lifecycle-aware components
  • Components in the back stack are not destroyed, they continue working in background without UI
  • State preservation (on Android and experimentally on Apple targets)
  • Instances retaining (aka ViewModels) over configuration changes (mostly useful in Android)

Setup

Please check the Installation section of the documentation.

Supported platforms

In general, Decompose supports the following targets: android, jvm, ios, watchos, tvos, macos, wasmJs, js. However, some modules do not support all targets or the support depends on the Decompose version. Please see the Installation docs for details.

Overview

Here are some key concepts of the library, more details can be found in the documentation.

  • Component - every component represents a piece of logic with its own lifecycle, the UI is optional and is plugged externally
  • ComponentContext - every component has its own [ComponentContext], which makes components lifecycle-aware and allows state preservation, instances retaining (aka AndroidX ViewModel) and back button handling
  • Child Stack - enables navigation between child components, nested navigation is also supported
  • Child Slot - allows only one child component at a time, or none
  • Child Pages - a list of child components with one selected component (e.g. pager-like navigation)
  • Generic Navigation - provides a way to create your own custom navigation model, when none of the predefined models fit your needs
  • Lifecycle - provides a way to listen for lifecycle events in components
  • StateKeeper - makes it possible to preserve state or data in a component when it gets destroyed
  • InstanceKeeper - retains instances in your components (similar to AndroidX ViewModel)
  • BackPressedHandler - provides a way to handle and intercept back button presses

Component hierarchy

Pluggable UI hierarchy

Typical component structure

Quick start

Please refer to the Quick start section of the docs.

Samples

Check out the Samples section of the docs for a full description of each sample.

Template

Check out the template repository which may be used to kick-start a project for you.

Articles

Author

Twitter: @arkann1985

If you like this project you can always Buy Me A Coffee ;-)

decompose's People

Contributors

alexzhirkevich avatar anton-avm avatar arkivanov avatar azlekov avatar c2h6o avatar chen-xi-g avatar darvld avatar datl4g avatar drinkthestars avatar eliavyair1 avatar girijakar avatar hamen avatar ivkosh avatar jimkarsh avatar malliaridis avatar maxtox3 avatar moffpage avatar mohamedrejeb avatar morfly avatar nikola-milovic avatar plusmobileapps avatar shabinder avatar steelahhh avatar theapache64 avatar tiebe avatar tommyten avatar ttypic avatar zikstar avatar zveljkovic avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.