| SwiftUI | Compose | Notes |
|---|---|---|
@State |
remember { mutableStateOf(...) } |
|
@Binding |
explicit value reading & onValueChange closures | Passing MutableState around is discouraged in Compose |
@ObservedObject/@StateObject |
ViewModel with StateFlow/LiveData |
|
EnvironmentKey/EnvironmentValues |
compositionLocalOf/statisCompositionLocalOf |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| alias: "System Notifications" | |
| description: "Sends persistent notifications to the companion app" | |
| triggers: | |
| - trigger: persistent_notification | |
| update_type: | |
| - added | |
| - removed | |
| - updated | |
| notification_id: "" | |
| conditions: [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class ViewModel { | |
| init() { | |
| // accessing underlying subject: | |
| $buttonTapped | |
| .asObservable() | |
| ... | |
| } | |
| // look ma, no explicit subject property |
Дисклеймер: речь идёт об однопоточном коде, оставим ужасы параллельного исполнения за скобками. Также не рассматривается возможность overrelease.
Объект точно не ритейнится на время выполнения его метода, пруфы:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #import <Foundation/Foundation.h> | |
| @interface Node: NSObject | |
| @property (nonatomic, weak) Node *parent; | |
| @property (nonatomic) NSArray *children; | |
| @end | |
| @implementation Node { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| class Child { | |
| deinit { | |
| print("Child.deinit") | |
| } | |
| var parent: Parent? | |
| func removeFromParent() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Cmake < Formula | |
| desc "Cross-platform make" | |
| homepage "https://www.cmake.org/" | |
| url "https://cmake.org/files/v3.12/cmake-3.12.4.tar.gz" | |
| sha256 "5255584bfd043eb717562cff8942d472f1c0e4679c4941d84baadaa9b28e3194" | |
| head "https://cmake.org/cmake.git" | |
| bottle do | |
| cellar :any_skip_relocation | |
| sha256 "7bcd5ae043d2a6fd5983b026ccdc70b7594e0dbe9de4d367cfcead7edf3c8596" => :mojave |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| protocol RemoteAPIDelegate: class { | |
| func remoteAPIDidLoadPosts(_ posts: NSArray) | |
| } | |
| class RemoteAPI { | |
| weak var delegate: RemoteAPIDelegate? | |
| func loadPosts() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| protocol ReachabilityDelegate: class { | |
| func reachabilityDidChange(_ reachable: Bool) | |
| } | |
| class Reachability { | |
| weak var delegate: ReachabilityDelegate? | |
| } | |
| class Model: ReachabilityDelegate { | |
| func reachabilityDidChange(_ reachable: Bool) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="UTF-8"?> | |
| <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
| <plist version="1.0"> | |
| <dict> | |
| <key>IDECodeSnippetCompletionPrefix</key> | |
| <string>auto</string> | |
| <key>IDECodeSnippetCompletionScopes</key> | |
| <array> | |
| <string>CodeBlock</string> | |
| </array> |
NewerOlder