(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
Modern Cocoa development involves a lot of asynchronous programming using closures and completion handlers, but these APIs are hard to use. This gets particularly problematic when many asynchronous operations are used, error handling is required, or control flow between asynchronous calls gets complicated. This proposal describes a language extension to make this a lot more natural and less error prone.
This paper introduces a first class Coroutine model to Swift. Functions can opt into to being async, allowing the programmer to compose complex logic involving asynchronous operations, leaving the compiler in charge of producing the necessary closures and state machines to implement that logic.
Currently it doesn't seem possible to execute additional logic when a navigation link is tapped with the new NavigationLink(value:)
initializer. When the link is tapped it updates path state all the way back at the root NavigationStack
to drive navigation, but there are many times where we need to perform logic after the tap and before the drill down.
For example, after tapping a link we may want to pre-emptively load some data to show on the drill down screen. Or we may want to perform some form validation. Or we may want to track some analytics. This does not seem possible with the current link API.
A workaround is to use Button
s instead of NavigationLink
s, but then you lose all of the styling and affordances given to links, such as chevrons when used in List
.
If the API for NavigationLink
cannot be changed to accomodate for this, perhaps a new ButtonStyle
could be introduced that allows regular buttons to take on the sty
# nil? can be used on any Ruby object. It returns true only if the object is nil. | |
nil.nil? # => true | |
[].nil? # => false | |
{}.nil? # => false | |
"".nil? # => false | |
" ".nil? # => false | |
true.nil? # => false | |
# empty? can be used on some Ruby objects including Arrays, Hashes and Strings. It returns true only if the object's length is zero. | |
nil.empty? # NoMethodError: undefined method `empty?' for nil:NilClass |
<% flash.each do |type, message| %> | |
<div class="alert <%= bootstrap_class_for(type) %> fade in"> | |
<button class="close" data-dismiss="alert">×</button> | |
<%= message %> | |
</div> | |
<% end %> |
UIModalPresentationStyle | iPhone | iPad | |
---|---|---|---|
.fullScreen | YES | YES | |
.pageSheet | YES | NO | |
.formSheet | YES | NO | |
.currentContext | YES | YES | |
.custom | NO | NO | |
.overFullScreen | NO | NO | |
.overCurrentContext | NO | NO | |
.blurOverFullScreen | only on tvOS - N/A | N/A | |
.popover | YES | NO |
func fetchUserId() -> Observable<String> { | |
return create{ (observer) -> Disposable in | |
Client.fetchUserId() { [unowned self] | |
(userId: String?, err: ErrorType?) -> Void in | |
if let _ = err{ | |
observer.on(Event.Error(err!)) | |
} else { | |
observer.on(Event.Next(userId)) | |
observer.on(Event.Completed) | |
} |
/* This SnapshotHelper class should be compatible with SnapshotHelper.swift version 1.2 */ | |
@import Foundation; | |
@import XCTest; | |
@interface SnapshotHelper : NSObject | |
- (instancetype)initWithApp:(XCUIApplication*)app; | |
- (void)snapshot:(NSString*)name waitForLoadingIndicator:(BOOL)wait; |
import Foundation | |
import Combine | |
@propertyWrapper | |
final class UserDefault<Wrapped>: NSObject, ObservableObject { | |
typealias Validator = (Wrapped) -> (Wrapped) | |
private let suite: UserDefaults | |
private let key: String |