Skip to content
This repository has been archived by the owner on Mar 16, 2020. It is now read-only.

Commit

Permalink
update to new project structure
Browse files Browse the repository at this point in the history
  • Loading branch information
JensRavens committed Dec 4, 2015
1 parent 7848153 commit 5ee1a73
Show file tree
Hide file tree
Showing 18 changed files with 123 additions and 173 deletions.
6 changes: 3 additions & 3 deletions Interstellar.podspec
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "Interstellar"
s.version = "1.3.0"
s.version = "1.4.0"
s.license = "MIT"
s.summary = "The simplest Signal<T> implementation for Functional Reactive Programming you will ever find."
s.homepage = "https://github.com/JensRavens/Interstellar"
Expand All @@ -14,12 +14,12 @@ Pod::Spec.new do |s|
s.tvos.deployment_target = "9.0"

s.subspec "Core" do |cs|
cs.source_files = "Interstellar/*.swift"
cs.source_files = ["Sources/Result.swift", "Sources/Signal.swift"]
end

s.subspec "Warpdrive" do |cs|
cs.dependency "Interstellar/Core"
cs.source_files = "Warpdrive/*.swift"
cs.source_files = ["Sources/Debounce.swift", "Sources/Delay.swift", "Sources/Threading.swift", "Sources/Waiting.swift"]
end

s.requires_arc = true
Expand Down
191 changes: 90 additions & 101 deletions Interstellar.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

67 changes: 0 additions & 67 deletions Interstellar/Compatibility.swift

This file was deleted.

8 changes: 8 additions & 0 deletions Warpdrive/Debounce.swift → Sources/Debounce.swift
Expand Up @@ -24,6 +24,8 @@ import Foundation

private var SignalUpdateCalledHandle: UInt8 = 0
public extension Signal {
#if os(Linux)
#else
internal var lastCalled: NSDate? {
get {
if let handle = objc_getAssociatedObject(self, &SignalUpdateCalledHandle) as? NSDate {
Expand All @@ -37,6 +39,11 @@ public extension Signal {
}
}

/**
Creates a new signal that is only firing once per specified time interval. The last
call to update will always be delivered (although it might be delayed up to the
specified amount of seconds).
*/
public func debounce(seconds: NSTimeInterval) -> Signal<T> {
let signal = Signal<T>()

Expand All @@ -62,4 +69,5 @@ public extension Signal {

return signal
}
#endif
}
3 changes: 3 additions & 0 deletions Warpdrive/Delay.swift → Sources/Delay.swift
Expand Up @@ -23,6 +23,8 @@
import Foundation

public extension Signal {
#if os(Linux)
#else
/**
Creates a new signal that mirrors the original signal but is delayed by x seconds. If no queue is specified, the new signal will call it's observers and transforms on the main queue.
*/
Expand All @@ -35,4 +37,5 @@ public extension Signal {
}
return signal;
}
#endif
}
File renamed without changes.
3 changes: 3 additions & 0 deletions Interstellar/Signal.swift → Sources/Signal.swift
Expand Up @@ -200,8 +200,11 @@ public final class Signal<T> {
about the new value.
*/
public func update(result: Result<T>) {
#if os(Linux)
#else
objc_sync_enter(self)
defer { objc_sync_exit(self) }
#endif
self.value = result
self.callbacks.forEach{$0(result)}
}
Expand Down
12 changes: 10 additions & 2 deletions Warpdrive/Threading.swift → Sources/Threading.swift
Expand Up @@ -22,30 +22,38 @@

import Foundation

/**
/**
Several functions that should make multithreading simpler.
Use this functions together with Signal.ensure:
Signal.ensure(Thread.main) // will create a new Signal on the main queue
*/
public final class Thread {

#if os(Linux)
#else
/// Transform a signal to the main queue
public static func main<T>(a: Result<T>, completion: Result<T>->Void) {
queue(dispatch_get_main_queue())(a, completion)
}
#endif

#if os(Linux)
#else
/// Transform the signal to a specified queue (despite the name this could also be the main queue)
public static func queue<T>(queue: dispatch_queue_t)(_ a: Result<T>, _ completion: Result<T>->Void) {
dispatch_async(queue){
completion(a)
}
}
#endif

#if os(Linux)
#else
/// Transform the signal to a global background queue with priority default
public static func background<T>(a: Result<T>, completion: Result<T>->Void) {
let q = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)
dispatch_async(q) {
completion(a)
}
}
#endif
}
6 changes: 6 additions & 0 deletions Warpdrive/Waiting.swift → Sources/Waiting.swift
Expand Up @@ -29,13 +29,18 @@ public struct TimeoutError: ErrorType {
internal init() {}
}

#if os(Linux)
#else
internal extension NSTimeInterval {
var dispatchTime: dispatch_time_t {
return dispatch_time(DISPATCH_TIME_NOW, Int64(self * Double(NSEC_PER_SEC)))
}
}
#endif

public extension Signal {
#if os(Linux)
#else
/**
Wait until the signal updates the next time. This will block the current thread until there
is an error or a successfull value. In case of an error, the error will be thrown.
Expand All @@ -57,4 +62,5 @@ public extension Signal {
case let .Error(e): throw e
}
}
#endif
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 5ee1a73

Please sign in to comment.