{"id":32109810,"url":"https://github.com/p0ed/fx","last_synced_at":"2025-10-20T13:06:29.842Z","repository":{"id":9014742,"uuid":"60541463","full_name":"P0ed/Fx","owner":"P0ed","description":"Functional tools","archived":false,"fork":false,"pushed_at":"2025-09-19T10:34:15.000Z","size":303,"stargazers_count":12,"open_issues_count":0,"forks_count":4,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-10-07T13:08:49.689Z","etag":null,"topics":["functional","functional-reactive-programming","promises","swift"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/P0ed.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2016-06-06T16:02:00.000Z","updated_at":"2025-09-19T10:34:19.000Z","dependencies_parsed_at":"2025-05-14T11:42:07.346Z","dependency_job_id":"5217b921-0319-43ef-8ad4-1847d73565e6","html_url":"https://github.com/P0ed/Fx","commit_stats":{"total_commits":156,"total_committers":4,"mean_commits":39.0,"dds":"0.22435897435897434","last_synced_commit":"606e01140b6b30b022293f9eddfd98e49f68f321"},"previous_names":[],"tags_count":39,"template":false,"template_full_name":null,"purl":"pkg:github/P0ed/Fx","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/P0ed%2FFx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/P0ed%2FFx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/P0ed%2FFx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/P0ed%2FFx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/P0ed","download_url":"https://codeload.github.com/P0ed/Fx/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/P0ed%2FFx/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280095066,"owners_count":26271047,"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","status":"online","status_checked_at":"2025-10-20T02:00:06.978Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["functional","functional-reactive-programming","promises","swift"],"created_at":"2025-10-20T13:06:28.556Z","updated_at":"2025-10-20T13:06:29.836Z","avatar_url":"https://github.com/P0ed.png","language":"Swift","readme":"# Fx\n[![codecov](https://codecov.io/gh/P0ed/Fx/branch/master/graph/badge.svg?token=6exeUP7sRY)](https://codecov.io/gh/P0ed/Fx)\n\nA Swift library providing functional programming utilities, reactive programming primitives, and asynchronous operations support.\n\n## Overview\n\nFx is a lightweight, zero-dependency Swift library that brings functional programming concepts and reactive programming patterns to Swift ecosystem. It provides a comprehensive set of utilities for:\n\n- **Functional Programming**: Higher-order functions, currying, composition, and more\n- **Reactive Programming**: Signals for event streams and reactive data flow\n- **Asynchronous Operations**: Promise-based async operations with modern Swift concurrency support\n- **Utility Extensions**: Convenient extensions for common Swift types\n\n## Features\n\n### Functional Programming Utilities\n- **Core Functions**: `id`, `const`, `curry`, `flip`, `compose`\n- **Function Combinators**: Transform and combine functions with ease\n- **Utility Functions**: `with`, `modify`, `transform` for cleaner code\n\n### Reactive Programming\n- **Signal**: Type-safe event streams with operators like `map`, `filter`, `merge`\n- **Property**: Observable properties with automatic change notifications\n- **Command**: Reactive command pattern implementation\n- **Disposables**: Automatic resource management\n\n### Asynchronous Operations\n- **Promise**: Modern promise implementation with Swift concurrency support\n- **Result Integration**: Seamless integration with Swift's Result type\n- **Async/Await Support**: Bridge between callback-based and async/await patterns\n\n### Extensions \u0026 Utilities\n- **Optional Extensions**: Enhanced optional handling\n- **Collection Extensions**: Functional operations on sequences\n- **Timer Extensions**: Reactive timer utilities\n- **KVO Extensions**: Simplified Key-Value Observing\n\n## Installation\n\n### Swift Package Manager\n\nAdd to your `Package.swift`:\n\n```swift\n.package(url: \"https://github.com/P0ed/Fx.git\", from: \"4.0.0\")\n```\n\n## Requirements\n\n- iOS 14.0+ / macOS 12.0+ / watchOS 8.0+ / tvOS 14.0+\n- Swift 6.1+\n- Xcode 16.0+\n\n## Key Features\n\n### Reactive Programming\n\n#### `Signal\u003cA\u003e` - Reactive Streams\n```swift\nlet numbers = Signal\u003cInt\u003e { sink in\n    // Emit values over time\n    return timer.observe(sink)\n}\n\nlet doubled = numbers\n    .filter { $0 \u003e 0 }\n    .map { $0 * 2 }\n    .throttled(0.1)\n```\n\n#### `Property\u003cA\u003e` \u0026 `MutableProperty\u003cA\u003e` - Reactive State\n```swift\nfinal class Model {\n    // Exposes readonly observable state\n    @MutableProperty\n    private(set) var count = 0\n}\n\n// Automatic UI updates\nlet isEven: Property\u003cBool\u003e = $count.map { $0 % 2 == 0 }\nisEven.observe { isEven in\n    button.isEnabled = isEven\n}\n```\n\n### Functional Programming\n\n#### Essential Functions\n```swift\n// Function composition\nlet nonEmpty = elements.filter(where: (!) • \\.isEmpty • \\.name)\n\n// Currying for partial application\nlet add = curry(+)\nlet inc = add(1)\n[1, 2, 3].map(inc) // [2, 3, 4]\n\n// Mutation without introducing a variable in current scope\nlet newArray = modify(array) { $0.append(item) }\n```\n\n#### Operators\n- `§` — Function application `⌥+6`\n- `•` — Function composition `⌥+8`  \n- `∑` — Monoid sum operator `⌥+W`\n\n#### Sendable \u0026 Concurrency Support\n```swift\n// Thread-safe signals\nlet signal = Signal\u003cString\u003e(sendable: generator)\n\n// Async/await integration  \nlet result = try await promise.get()\n```\n\n## Core Types\n\n### Reactive Types\n- **`Signal\u003cA\u003e`** - Stream of values over time with operators like `map`, `filter`, `merge`, `combineLatest`\n- **`Property\u003cA\u003e`** - Current value + change notifications, perfect for UI binding\n- **`MutableProperty\u003cA\u003e`** - Mutable reactive property with property wrapper support\n\n### Functional Types\n- **`Result\u003cA, Error\u003e`** - Enhanced with functional operators\n- **`Monoid`** - Types that can be combined (strings, arrays, etc.)\n- **`IO\u003cA\u003e`** - Controlled side effects\n- **`Atomic\u003cA\u003e`** - Thread-safe value container\n\n### Utility Types\n- **`Disposable`** - Resource cleanup and subscription management\n- **`Weak\u003cA\u003e`** - Weak reference wrapper\n- **`Bag\u003cA\u003e`** - Efficient collection for callbacks\n\n### From Promises to Async/Await\n```swift\n// Old Promise-based approach\nfunc fetchData() -\u003e Promise\u003cData\u003e { ... }\n\n// Modern async/await (recommended)\nfunc fetchData() async throws -\u003e Data { ... }\n\n// Bridge when needed\nlet promise = Promise.async { try await fetchData() }\n\n// And backwards\nlet data = try await promise.get()\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fp0ed%2Ffx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fp0ed%2Ffx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fp0ed%2Ffx/lists"}