{"id":44279176,"url":"https://github.com/kevincianfarini/monarch","last_synced_at":"2026-02-10T21:16:48.876Z","repository":{"id":217753038,"uuid":"559985324","full_name":"kevincianfarini/monarch","owner":"kevincianfarini","description":"Multiplatform, multi module, type safe feature flagging. ","archived":false,"fork":false,"pushed_at":"2026-02-05T10:56:36.000Z","size":879,"stargazers_count":83,"open_issues_count":24,"forks_count":2,"subscribers_count":1,"default_branch":"trunk","last_synced_at":"2026-02-05T22:20:15.269Z","etag":null,"topics":["android","environment","environment-variables","feature-flags","jetpack-compose","kotlin","kotlin-coroutines","kotlin-multiplatform","kotlinx-coroutines","kotlinx-serialization","launch-darkly"],"latest_commit_sha":null,"homepage":"https://kevincianfarini.github.io/monarch/docs/0.x/","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/kevincianfarini.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2022-10-31T14:06:11.000Z","updated_at":"2025-12-05T00:51:59.000Z","dependencies_parsed_at":"2025-12-05T05:00:48.817Z","dependency_job_id":null,"html_url":"https://github.com/kevincianfarini/monarch","commit_stats":null,"previous_names":["kevincianfarini/monarch"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/kevincianfarini/monarch","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevincianfarini%2Fmonarch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevincianfarini%2Fmonarch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevincianfarini%2Fmonarch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevincianfarini%2Fmonarch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kevincianfarini","download_url":"https://codeload.github.com/kevincianfarini/monarch/tar.gz/refs/heads/trunk","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevincianfarini%2Fmonarch/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29317074,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-10T20:44:44.282Z","status":"ssl_error","status_checked_at":"2026-02-10T20:44:43.393Z","response_time":65,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["android","environment","environment-variables","feature-flags","jetpack-compose","kotlin","kotlin-coroutines","kotlin-multiplatform","kotlinx-coroutines","kotlinx-serialization","launch-darkly"],"created_at":"2026-02-10T21:16:48.704Z","updated_at":"2026-02-10T21:16:48.845Z","avatar_url":"https://github.com/kevincianfarini.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Monarch 🦋\n\nMonarch is a small, flexible, type safe, and multiplatform abstraction for feature flags.  \n\n\u003e In chaos theory, the butterfly effect is the sensitive dependence on initial conditions in which a small change in one state of a deterministic nonlinear system can result in large differences in a later state.\n\u003e \n\u003e — [Wikipedia](https://en.wikipedia.org/wiki/Butterfly_effect)\n\n## Download\n\n```toml\n[versions]\nmonarch = \"0.2.2\"\n\n[libraries]\nmonarch-compose = { module = \"io.github.kevincianfarini.monarch:compose\", version.ref = \"monarch\" }\nmonarch-core = { module = \"io.github.kevincianfarini.monarch:core\", version.ref = \"monarch\" }\nmonarch-integration-environment = { module = \"io.github.kevincianfarini.monarch:environment-integration\", version.ref = \"monarch\" }\nmonarch-integration-launchdarkly = { module = \"io.github.kevincianfarini.monarch:launch-darkly-integration\", version.ref = \"monarch\" }\nmonarch-mixin-kotlinxjson = { module = \"io.github.kevincianfarini.monarch:kotlinx-serialization-mixin\", version.ref = \"monarch\" }\nmonarch-test = { module = \"io.github.kevincianfarini.monarch:test\", version.ref = \"monarch\" }\n```\n\n## Usage \n\n### Defining flags\n\nMonarch provides compile time safety for the feature flags you define and consume.\nFlag keys are bound to a type and a default value. \n\n```kt\nobject FancyFeatureEnabled : BooleanFeatureFlag(\n    key = \"fancy_feature_enabled\",\n    default = false,\n)\n```\n\nThe `FancyFeatureEnabled` flag can later be referenced in code and checked by the compiler. \n\nMonarch provides several feature flag types in the 'core' artifact. \n\n* `BooleanFeatureFlag`\n* `LongFeatureFlag`\n* `DoubleFeatureFlag`\n* `StringFeatureFlag`\n\n### Obtaining values\n\nValues can be obtained from a `FeatureFlagManager` for a given feature flag.\n\n```kt\nfun showFeature(manager: FeatureFlagManager) {\n    if (manager.currentValueOf(FancyFeatureEnabled)) {\n        showFancyFeature()\n    } else {\n        showBoringFeature()\n    }\n}\n```\n\n### Observing value changes as a Flow\n\nSome third party SDKs, like LaunchDarkly, provide callbacks for flags when their values change.\nMonarch provides an additional abstraction for this, called `ObservableFeatureFlagManager`,\nwhich exposes these changes as a `Flow`.\n\n```kt\nsuspend fun showFeature(manager: ObservableFeatureFlagManager) {\n    manager.valuesOf(FancyFeatureEnabled).collect { enabled -\u003e \n        if (enabled) {\n            showFancyFeature()\n        } else {\n            showBoringFeature()\n        }\n    }\n}\n```\n\n### Observing value changes as a Compose State\n\nMonarch offers a companion artifact that makes observing flag values as Compose State simple.\n\n```kotlin\n@Composable \nfun ShowFeature(manager: ObservableFeatureFlagManager) {\n    val enabled by manager.stateOf(FancyFeatureEnabled)\n    if (enabled) {\n        FancyFeature()\n    } else {\n        BoringFeature()\n    }\n}\n```\n\n### Testing\n\nMonarch provides an out-of-the-box test implementation of an `ObservableFeatureFlagManager` called `InMemoryFeatureFlagManager`.\nIt can be mutated under test to exercise specific branches of code dictated by your flags.\n\n```kotlin\n@Test \nfun test_flag_changes() = runTest {\n   val manager = InMemoryFeatureFlagManager()\n   manager.valuesOf(FancyFeatureEnabled).test {\n       assertFalse(awaitItem())\n       manager.setCurrentValueOf(FancyFeatureEnabled, true)\n       assertTrue(awaitItem())\n   }\n}\n```\n\n### Supplying a FeatureFlagManager\n\nMonarch's built-in implementations of `FeatureFlagManager` take lists of\n`FeatureFlagManagerMixin` and a `FeatureFlagDataStore`.\n\nA `FeatureFlagDataStore` is the entity closely tied to the underlying feature flagging SDK. \nIt's unlikely you will implement this unless you're integrating with a feature flagging platform \nthat Monarch doesn't currently support. \n\nTypical usage of `FeatureFlagManager` implementations expects that the `FeatureFlagDataStore`, \nall `FeatureFlagManagerMixin` instances, and the `FeatureFlagManager` itself will be provided\nas part of your dependency graph. Below is a sample with Dagger. \n\n```kt\n@Module object FeatureFlaggingModule {\n    \n    @Provides \n    fun providesDataStore(): FeatureFlagDataStore { /* omitted */ }\n    \n    @Provides @IntoSet \n    fun providesJsonMixin(\n        json: Json\n    ): FeatureFlagManagerMixin = JsonFeatureFlagManagerMixin(json)\n    \n    @Provides \n    fun providesManager(\n        dataStore: FeatureFlagDataStore, \n        mixins: Set\u003cFeatureFlagManagerMixin\u003e,\n    ): FeatureFlagManager = MixinFeatureFlagManager(\n        store = dataStore, \n        mixins = mixins.toList(),\n    )\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkevincianfarini%2Fmonarch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkevincianfarini%2Fmonarch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkevincianfarini%2Fmonarch/lists"}