GithubHelp home page GithubHelp logo

lachenmayer / asyncextensions Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sideeffect-io/asyncextensions

0.0 1.0 0.0 159 KB

AsyncExtensions aims to mimic Swift Combine operators for async sequences.

License: MIT License

Swift 100.00%

asyncextensions's Introduction

AsyncExtensions

Build Status AsyncExtensions supports Swift Package Manager (SPM)

AsyncExtensions provides a collection of operators that intends to ease the creation and combination of AsyncSequences.

AsyncExtensions can be seen as a companion to Apple swift-async-algorithms, which provides operators that the community needs and are not provided by Apple.

Adding AsyncExtensions as a Dependency

To use the AsyncExtensions library in a SwiftPM project, add the following line to the dependencies in your Package.swift file:

.package(url: "https://github.com/sideeffect-io/AsyncExtensions"),

Include "AsyncExtensions" as a dependency for your executable target:

.target(name: "<target>", dependencies: ["AsyncExtensions"]),

Finally, add import AsyncExtensions to your source code.

Features

Channels

Subjects

Combiners

  • merge(_:): Merges any AsyncSequence into an AsyncSequence of elements
  • withLatest(_:): Combines elements from self with the last known element from an other AsyncSequence
  • withLatest(_:_:): Combines elements from self with the last known elements from two other async sequences

Creators

Operators

  • handleEvents(): Executes closures during the lifecycle of the self
  • mapToResult(): Maps elements and failure from self to a Result type
  • prepend(_:): Prepends an element to self
  • scan(_:_:): Transforms elements from self by providing the current element to a closure along with the last value returned by the closure
  • assign(_:): Assigns elements from self to a property
  • collect(_:): Iterate over elements from self and execute a closure
  • eraseToAnyAsyncSequence(): Erases to AnyAsyncSequence
  • flatMapLatest(_:): Transforms elements from self into a AsyncSequence and republishes elements sent by the most recently received AsyncSequence when self is an AsyncSequence of AsyncSequence
  • multicast(_:): Shares values from self to several consumers thanks to a provided Subject
  • share(): Shares values from self to several consumers
  • switchToLatest(): Republishes elements sent by the most recently received AsyncSequence when self is an AsyncSequence of AsyncSequence

More operators and extensions are to come. Pull requests are of course welcome.

asyncextensions's People

Contributors

jordanekay avatar lachenmayer avatar prince2k3 avatar swhitty avatar twittemb avatar

Watchers

 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.