Giter Club home page Giter Club logo

jetpack's Introduction

Jetpack

Jetpack is a lightweight reactive programming library for Swift. It provides tools for creating and composing asynchronous and event-based programs using observable sequences.

Features

  • Observable sequences
  • Mutable and immutable property wrappers
  • Combining and transforming observables
  • Threading and concurrency utilities
  • Array and 2D array reactive wrappers
  • Reactive subjects for broadcasting values

Usage

import Jetpack

// Create an observable sequence
let observable = Observable.just(5)

// Subscribe to receive values
observable.subscribe { value in
    print(value) // Prints: 5
}

// Create a mutable property
let property = MutableProperty(10)

// Observe property changes
property.subscribe { value in
    print(value)
}

property.update(20) // Triggers subscription, prints: 20

// Combine observables
let combined = observable.combineLatest(property.asObservable)
combined.subscribe { (a, b) in
    print("Combined: \(a), \(b)")
}

// Transform observables
let mapped = observable.map { $0 * 2 }
mapped.subscribe { value in
    print(value) // Prints: 10
}

Main Components

  • Observable: Represents a sequence of values over time
  • Property: Immutable wrapper around a value with reactive capabilities
  • MutableProperty: Mutable version of Property
  • Subject: Allows broadcasting values to multiple observers

Threading

Jetpack provides utilities for managing concurrency:

observable.dispatch(on: .main) // Observe on main thread
observable.delay(timeInterval: 1.0, on: .global()) // Delay events

Installation

Swift Package Manager

Add the following to your Package.swift file:

dependencies: [
    .package(url: "https://github.com/username/Jetpack.git", from: "1.0.0")
]

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

Jetpack is released under the MIT License. See LICENSE for details.

jetpack's People

Contributors

psharanda avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  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.