Skip to content

Commit

Permalink
Starting new documentation structure (#6)
Browse files Browse the repository at this point in the history
New Documentation Structure

Signed-off-by: EandJsFilmCrew <789213+rvsrvs@users.noreply.github.com>
  • Loading branch information
rvsrvs authored Jun 4, 2022
1 parent 0307727 commit 997e959
Show file tree
Hide file tree
Showing 50 changed files with 225 additions and 62 deletions.
1 change: 1 addition & 0 deletions Documentation/Bibliography.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

File renamed without changes.
26 changes: 0 additions & 26 deletions Playgrounds/98-Merge.playground/Contents.swift

This file was deleted.

4 changes: 0 additions & 4 deletions Playgrounds/98-Merge.playground/contents.xcplayground

This file was deleted.

25 changes: 0 additions & 25 deletions Playgrounds/99-Zip.playground/Contents.swift

This file was deleted.

2 changes: 0 additions & 2 deletions Playgrounds/99-Zip.playground/contents.xcplayground

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Task {
try await fsubject2.send("hello, combined world!")
try await fsubject1.finish()
try await fsubject2.finish()
let finalDemand = try await fcancellable.task.value
let finalDemand = try await fcancellable.value
print(finalDemand)
}

Expand Down
3 changes: 3 additions & 0 deletions Playgrounds/Operators.playground/Contents.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import UIKit

var greeting = "Hello, playground"
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//: [Previous](@previous)

import Foundation

var greeting = "Hello, playground"

//: [Next](@next)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//: [Previous](@previous)

import Foundation

var greeting = "Hello, playground"

//: [Next](@next)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//: [Previous](@previous)

import Foundation

var greeting = "Hello, playground"

//: [Next](@next)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//: [Previous](@previous)

import Foundation

var greeting = "Hello, playground"

//: [Next](@next)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//: [Previous](@previous)

import Foundation

var greeting = "Hello, playground"

//: [Next](@next)
4 changes: 4 additions & 0 deletions Playgrounds/Operators.playground/contents.xcplayground
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<playground version='5.0' target-platform='ios' buildActiveScheme='true' executeOnSourceChanges='false' importAppTypes='true'>
<timeline fileName='timeline.xctimeline'/>
</playground>
6 changes: 6 additions & 0 deletions Playgrounds/Operators.playground/timeline.xctimeline
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Timeline
version = "3.0">
<TimelineItems>
</TimelineItems>
</Timeline>
3 changes: 3 additions & 0 deletions Playgrounds/Publishers.playground/Contents.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import UIKit

var greeting = "Hello, playground"
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//: [Previous](@previous)

import Foundation

var greeting = "Hello, playground"

//: [Next](@next)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//: [Previous](@previous)

import Foundation

var greeting = "Hello, playground"

//: [Next](@next)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//: [Previous](@previous)

import Foundation

var greeting = "Hello, playground"

//: [Next](@next)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//: [Previous](@previous)

import Foundation

var greeting = "Hello, playground"

//: [Next](@next)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//: [Previous](@previous)

import Foundation

var greeting = "Hello, playground"

//: [Next](@next)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//: [Previous](@previous)

import Foundation

var greeting = "Hello, playground"

//: [Next](@next)
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//: [Previous](@previous)

import FreeCombine
import PlaygroundSupport
PlaygroundPage.current.needsIndefiniteExecution = true

var count = 0
var publisher1 = (0 ... 100).asyncPublisher
var publisher2 = "abcdefghijklmnopqrstuvwxyz".asyncPublisher

let cancellable = Zipped(publisher1, publisher2)
.map { ($0.0 + 100, $0.1.uppercased()) }
.sink(onStartup: .none) { result in
switch result {
case let .value(value):
print(value)
count += 1
case let .completion(.failure(error)):
print("WTF? \(error)")
case .completion(.finished):
print("Done")
case .completion(.cancelled):
print("Cancelled")
}
return .more
}

cancellable

//: [Next](@next)
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//: [Previous](@previous)
import FreeCombine
import PlaygroundSupport
import _Concurrency

PlaygroundPage.current.needsIndefiniteExecution = true

var publisher1 = "01234567890123".asyncPublisher
var publisher2 = "abcdefghijklmnopqrstuvwxyz".asyncPublisher

Task {
let c = await Merged(publisher1, publisher2)
.map { $0.uppercased() }
.sink({ result in
switch result {
case let .value(value):
print(value)
return .more
case let .completion(.failure(error)):
print("WTF? \(error)")
return .done
case .completion(.finished):
print("Done")
return .done
case .completion(.cancelled):
print("Done")
return .done
}
})
_ = try await c.value
}

//: [Next](@next)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//: [Previous](@previous)

import Foundation

var greeting = "Hello, playground"

//: [Next](@next)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//: [Previous](@previous)

import Foundation

var greeting = "Hello, playground"

//: [Next](@next)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//: [Previous](@previous)

import Foundation

var greeting = "Hello, playground"

//: [Next](@next)
16 changes: 16 additions & 0 deletions Playgrounds/Publishers.playground/contents.xcplayground
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<playground version='6.0' target-platform='ios' buildActiveScheme='true' importAppTypes='true'>
<pages>
<page name='01-Just'/>
<page name='02-Empty'/>
<page name='03-Fail'/>
<page name='04-Unfolded'/>
<page name='05-Deferred'/>
<page name='06-Concat'/>
<page name='07-Zipped'/>
<page name='08-Merged'/>
<page name='09-CombineLatest'/>
<page name='10-Heartbeat'/>
<page name='11-FireAndForget'/>
</pages>
</playground>
6 changes: 6 additions & 0 deletions Playgrounds/Publishers.playground/timeline.xctimeline
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Timeline
version = "3.0">
<TimelineItems>
</TimelineItems>
</Timeline>
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

* Protocol-free.
* Race-free.
* Yield-free.
* Sleep-free.
* Lock-free.
* Leak-free.
* Dependency-free.
Expand Down
2 changes: 0 additions & 2 deletions Sources/FreeCombine/Combinator/ZipState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ struct ZipState<Left: Sendable, Right: Sendable>: CombinatorState {
case setRight(AsyncStream<Right>.Result, UnsafeContinuation<Demand, Swift.Error>)
}

let channel: Channel<ZipState<Left, Right>.Action>
let downstream: (AsyncStream<(Left, Right)>.Result) async throws -> Demand
let leftCancellable: Cancellable<Demand>
let rightCancellable: Cancellable<Demand>
Expand All @@ -27,7 +26,6 @@ struct ZipState<Left: Sendable, Right: Sendable>: CombinatorState {
left: Publisher<Left>,
right: Publisher<Right>
) async {
self.channel = channel
self.downstream = downstream
self.mostRecentDemand = mostRecentDemand
self.leftCancellable = await channel.consume(publisher: left, using: ZipState<Left, Right>.Action.setLeft)
Expand Down
File renamed without changes.
22 changes: 22 additions & 0 deletions Sources/FreeCombine/Filter/Filter.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//
// File.swift
//
//
// Created by Van Simmons on 6/4/22.
//
public extension Publisher {
func filter(
_ isIncluded: @escaping (Output) async -> Bool
) -> Self {
.init { continuation, downstream in
self(onStartup: continuation) { r in
switch r {
case .value(let a):
guard await isIncluded(a) else { return .more }
return try await downstream(r)
case let .completion(value):
return try await downstream(.completion(value))
} }
}
}
}
1 change: 0 additions & 1 deletion Sources/FreeCombine/Publishers/Combinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ public extension Publisher {
stateTask.cancel()
onCancel()
}) {
guard continuation != nil else { fatalError("Should have a continuation here") }
continuation?.resume()
guard !Task.isCancelled else {
throw PublisherError.cancelled
Expand Down
1 change: 0 additions & 1 deletion Sources/FreeCombine/Publishers/Zipped.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public func Zipped<Left, Right>(
}

public func zip<Left, Right>(
onStartup: UnsafeContinuation<Void, Never>? = .none,
onCancel: @escaping () -> Void = { },
_ left: Publisher<Left>,
_ right: Publisher<Right>
Expand Down

0 comments on commit 997e959

Please sign in to comment.