{"id":15629760,"url":"https://github.com/skydoves/bundler","last_synced_at":"2025-10-24T12:01:41.274Z","repository":{"id":51675287,"uuid":"308888648","full_name":"skydoves/Bundler","owner":"skydoves","description":"🎁 Android Intent \u0026 Bundle extensions that insert and retrieve values elegantly.","archived":false,"fork":false,"pushed_at":"2021-04-19T15:45:57.000Z","size":413,"stargazers_count":264,"open_issues_count":1,"forks_count":11,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-09T16:18:20.558Z","etag":null,"topics":["activity","android","bundle","bundler","fragment","intent","kotlin","kotlin-extensions","skydoves"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/skydoves.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null},"funding":{"github":"skydoves","custom":["https://www.paypal.me/skydoves","https://www.buymeacoffee.com/skydoves"]}},"created_at":"2020-10-31T13:32:15.000Z","updated_at":"2024-12-19T14:21:00.000Z","dependencies_parsed_at":"2022-08-22T04:40:20.853Z","dependency_job_id":null,"html_url":"https://github.com/skydoves/Bundler","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skydoves%2FBundler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skydoves%2FBundler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skydoves%2FBundler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skydoves%2FBundler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/skydoves","download_url":"https://codeload.github.com/skydoves/Bundler/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248065281,"owners_count":21041872,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["activity","android","bundle","bundler","fragment","intent","kotlin","kotlin-extensions","skydoves"],"created_at":"2024-10-03T10:28:35.202Z","updated_at":"2025-10-24T12:01:41.182Z","avatar_url":"https://github.com/skydoves.png","language":"Kotlin","readme":"\n\u003ch1 align=\"center\"\u003eBundler\u003c/h1\u003e\u003c/br\u003e\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://opensource.org/licenses/Apache-2.0\"\u003e\u003cimg alt=\"License\" src=\"https://img.shields.io/badge/License-Apache%202.0-blue.svg\"/\u003e\u003c/a\u003e\n  \u003ca href=\"https://android-arsenal.com/api?level=16\"\u003e\u003cimg alt=\"API\" src=\"https://img.shields.io/badge/API-16%2B-brightgreen.svg?style=flat\"/\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/skydoves/Bundler/actions\"\u003e\u003cimg alt=\"Build Status\" src=\"https://github.com/skydoves/Bundler/workflows/Android%20CI/badge.svg\"/\u003e\u003c/a\u003e\n  \u003ca href=\"https://androidweekly.net/issues/issue-439\"\u003e\u003cimg alt=\"Android Weekly\" src=\"https://skydoves.github.io/badges/android-weekly.svg\"/\u003e\u003c/a\u003e\n  \u003ca href=\"https://mailchi.mp/kotlinweekly/kotlin-weekly-225\"\u003e\u003cimg alt=\"KotlinWeekly\" src=\"https://skydoves.github.io/badges/kotlin-weekly.svg\"/\u003e\u003c/a\u003e\n  \u003ca href=\"https://skydoves.medium.com/clean-ways-to-handle-android-bundles-40af734bab3\"\u003e\u003cimg alt=\"Medium\" src=\"https://skydoves.github.io/badges/Story-Medium.svg\"/\u003e\u003c/a\u003e\n  \u003ca href=\"https://skydoves.github.io/libraries/bundler/html/bundler/com.skydoves.bundler/index.html\"\u003e\u003cimg alt=\"Javadoc\" src=\"https://skydoves.github.io/badges/javadoc-bundler.svg\"/\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n🎁 Android Intent \u0026 Bundle extensions that insert and retrieve values elegantly.\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"https://user-images.githubusercontent.com/24237865/97807630-3dfb6800-1ca5-11eb-9887-3e3c51aabb95.png\" width=\"471\" height=\"316\"/\u003e\n\u003c/p\u003e\n\n## Including in your project\n[![Maven Central](https://img.shields.io/maven-central/v/com.github.skydoves/bundler.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22com.github.skydoves%22%20AND%20a:%22bundler%22) [![Jitpack](https://jitpack.io/v/skydoves/bundler.svg)](https://jitpack.io/#skydoves/bundler)\n### Gradle \nAdd below codes to your **root** `build.gradle` file (not your module build.gradle file).\n```gradle\nallprojects {\n    repositories {\n        mavenCentral()\n    }\n}\n```\nAnd add a dependency code to your **module**'s `build.gradle` file.\n```gradle\ndependencies {\n    implementation \"com.github.skydoves:bundler:1.0.4\"\n}\n```\n## SNAPSHOT \n[![Bundler](https://img.shields.io/static/v1?label=snapshot\u0026message=bundler\u0026logo=apache%20maven\u0026color=C71A36)](https://oss.sonatype.org/content/repositories/snapshots/com/github/skydoves/bundler/) \u003cbr\u003e\nSnapshots of the current development version of Bundler are available, which track [the latest versions](https://oss.sonatype.org/content/repositories/snapshots/com/github/skydoves/bundler/).\n```Gradle\nrepositories {\n   maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }\n}\n```\n\n## Usage\n### Intent\n`intentOf` is an expression for creating an Intent using Kotlin DSL style and we can put extras using the `putExtra` method. Also, we can put extras using the `+` keyword in front of a key/value pair.\n```kotlin\nval intent = intentOf {\n    putExtra(\"posterId\", poster.id) // put a Long type 'posterId' value.\n    putExtra(\"posterName\" to poster.name) // put a String type 'posterName' value.\n    putExtra(\"poster\", poster) // put a Parcelable type 'poster' value.\n\n    +(\"id\" to userInfo.id) // put a Long type 'id' value.\n    +(\"name\" to userInfo.nickname) // put a String type 'name' value.\n    \n    -\"name\" // remove a String type 'name' value.\n}\n```\n### StartActivity\nWe can start activities using the `intentOf` expression like below.\n```kotlin\nintentOf\u003cSecondActivity\u003e {\n    putExtra(\"id\" to userInfo.id)\n    putExtra(\"name\" to userInfo.nickname)\n    putExtra(\"poster\", poster)\n    startActivity(this@MainActivity)\n}\n```\nWe can also use other options for creating an intent.\n```kotlin\nintentOf {\n    setAction(Intent.ACTION_MAIN)\n    addCategory(Intent.CATEGORY_APP_MUSIC)\n    setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)\n    startActivity(this@MainActivity)\n}\n```\n### bundle\n`bundle` is an expression for initializing lazily extra values from the intent.\n```kotlin\nclass SecondActivity : AppCompatActivity() {\n\n  private val id: Long by bundle(\"id\", -1) // initializes a Long extra value lazily.\n  private val name: String by bundle(\"name\", \"\") // initializes a String extra value lazily.\n  private val poster: Poster? by bundle(\"poster\") // initializes a Parcelable extra value lazily.\n\n  // -- stubs -- //\n```\nWe can initialize a Parcelable value with a defaut value.\n```kotlin\nprivate val poster: Poster? by bundle(\"poster\") { Poster.create() }\n```\nAlso, we can initialize type of Array and ArrayList using `bundleArray` and `bundleArrayList` expression.\n```kotlin\n// initialize lazily without default values.\nprivate val posterArray by bundleArray\u003cPoster\u003e(\"posterArray\")\nprivate val posterListArray by bundleArrayList\u003cPoster\u003e(\"posterArrayList\")\n\nor\n\n// initialize lazily with default values.\nprivate val posterArray by bundleArray\u003cPoster\u003e(\"posterArray\") { arrayOf() }\nprivate val posterListArray by bundleArrayList\u003cPoster\u003e(\"posterArrayList\") { arrayListOf() }\n```\n### bundle in Fragment\nThe below example shows setting arguments using the `intentOf` expression.\n```kotlin\narguments = intentOf {\n    +(\"id\" to userInfo.id)\n    +(\"name\" to userInfo.nickname)\n    +(\"poster\" to poster)\n}.extras\n```\nWe can initialize argument values lazily in Fragments using the `bundle` expression like below.\n```diff\n- val id: Long = arguments?.getLong(\"id\", -1) ?: -1\n+ val id: Long by bundle(\"id\", -1)\n- val poster: Poster? = arguments?.getParcelable(\"poster\")\n+ val poster: Poster? by bundle(\"poster\")\n```\n\n### bundleNonNull\nThe `bundle` expression for initializing objects (e.g. Bundle, CharSequence, Parcelable, Serializable, Arrays), the property type must be null-able. But If we want to initialize them non-nullable type, we can initialize them to non-nullable type using the `bundleNonNull` expression.\n```diff\n- val poster: Poster? by bundle(\"poster\")\n+ val poster: Poster by bundleNotNull(\"poster\")\n```\n\n### observeBundle\nWe can observe the bundle data as `LiveData` using the `observeBundle` expression. If there are no extra \u0026 arguments in the Activity or Fragment, `null` will be passed to the observers. The `observeBundle` emits data only a single time to a single observer. So We can observe only once using one observer. And the observer will be unregistered from the LiveData after observing data at once.\n```kotlin\nprivate val id: LiveData\u003cLong\u003e by observeBundle(\"id\", -1L)\nprivate val poster: LiveData\u003cPoster\u003e by observeBundle(\"poster\")\n\nid.observe(this) {\n  vm.id = it\n}\n\nposter.observe(this) {\n  binding.name = it.name\n}\n```\n\n### bundleValue\nWe can also retrieve intent \u0026 arguments extra values from Activity and Fragment immediately. We can use `bundleValue`, `bundleNonNullValue`, `bundleArrayValue`, `bundleArrayListValue`.\n\n```kotlin\nval id = bundleValue(\"id\", 100L)\nval name = bundleValue(\"name\", \"\")\nval poster = bundleValue\u003cPoster\u003e(\"poster\")\n```\n\n## Find this library useful? :heart:\nSupport it by joining __[stargazers](https://github.com/skydoves/bundler/stargazers)__ for this repository. :star: \u003cbr\u003e\nAnd __[follow](https://github.com/skydoves)__ me for my next creations! 🤩\n\n# License\n```xml\nCopyright 2020 skydoves (Jaewoong Eum)\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n   http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n","funding_links":["https://github.com/sponsors/skydoves","https://www.paypal.me/skydoves","https://www.buymeacoffee.com/skydoves"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskydoves%2Fbundler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fskydoves%2Fbundler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskydoves%2Fbundler/lists"}