https://pub.dev/documentation/riverpod/latest/all/FutureProvider-class.html
final futureProvider1 = FutureProvider<Model>((_) async {
final model = await AsyncFunc();
public extension Array { | |
/// Secure access at index. | |
/// | |
/// let array = [1, 2] | |
/// array[safe: 0] // Optional(1) | |
/// array[safe: 1] // Optional(2) | |
/// array[safe: 2] // nil | |
subscript (safe index: Index) -> Element? { | |
return indices.contains(index) ? self[index] : nil |
/* | |
before | |
fun asyncLoad(callback: (result: String) -> Unit) { | |
load { result -> | |
callback(result) | |
} | |
} | |
*/ | |
suspend fun asyncLoad(): String = suspendCoroutine { continuation -> |
class ViewController: UIViewController { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
let gesture = UITapGestureRecognizer() | |
gesture.numberOfTapsRequired = 2 // ここで回数を設定する | |
gesture.rx.event.asSignal() | |
.emit(onNext: { [weak self] _ in | |
// do somthing... |
import APIKit | |
import Foundation | |
protocol APIRequest: Request {} | |
// https://github.com/ishkawa/APIKit/issues/121 | |
// https://stackoverflow.com/questions/47983026/error-copying-matching-creds-swift-rest-api-call | |
extension APIRequest { | |
var baseURL: URL { | |
return URL(string: "https://api.xxx.com")! |
// legacy | |
public boolean onKeyDown(int keyCode, KeyEvent event) { | |
if (keyCode == KeyEvent.KEYCODE_BACK){ | |
// do something... | |
} else { | |
return super.onKeyDown(keyCode, event); | |
} | |
} |
import UIKit | |
class ItemTableViewCell: UITableViewCell { | |
@IBOutlet weak var collectionView: UICollectionView! { | |
didSet { | |
let nib = UINib(nibName: "ItemCollectionViewCell", bundle: nil) | |
collectionView.register(nib, forCellWithReuseIdentifier: "ItemCollectionViewCell") | |
} | |
} |
if [ `git branch --list $branch_name` ]; then | |
echo "Branch name $branch_name already exists." | |
else | |
echo "Branch named $branch_name does not exist" | |
fi |
https://pub.dev/documentation/riverpod/latest/all/FutureProvider-class.html
final futureProvider1 = FutureProvider<Model>((_) async {
final model = await AsyncFunc();