当前位置: 首页 > news >正文

直播网站开发要多久成都网站制作电话

直播网站开发要多久,成都网站制作电话,wordpress怎么跟vue,怎么看网站开发语言Combine 系列 Swift Combine 从入门到精通一Swift Combine 发布者订阅者操作者 从入门到精通二Swift Combine 管道 从入门到精通三Swift Combine 发布者publisher的生命周期 从入门到精通四Swift Combine 操作符operations和Subjects发布者的生命周期 从入门到精通五Swift Com…Combine 系列 Swift Combine 从入门到精通一Swift Combine 发布者订阅者操作者 从入门到精通二Swift Combine 管道 从入门到精通三Swift Combine 发布者publisher的生命周期 从入门到精通四Swift Combine 操作符operations和Subjects发布者的生命周期 从入门到精通五Swift Combine 订阅者Subscriber的生命周期 从入门到精通六Swift 使用 Combine 进行开发 从入门到精通七Swift 使用 Combine 管道和线程进行开发 从入门到精通八Swift Combine 使用 sink, assign 创建一个订阅者 从入门到精通九Swift Combine 使用 dataTaskPublisher 发起网络请求 从入门到精通十Swift Combine 用 Future 来封装异步请求 从入门到精通十一 目的使用 Combine 的管道来显式地对异步操作进行排序 这类似于一个叫做 “promise chaining” 的概念。 虽然你可以将 Combine 处理的和其行为一致但它可能不能良好地替代对 promise 库的使用。 主要区别在于promise 库总是将每个 promise 作为单一结果处理而 Combine 带来了可能需要处理许多值的复杂性。 任何需要按特定顺序执行的异步或同步任务组都可以使用 Combine 管道进行协调管理。 通过使用 Future 操作符可以捕获完成异步请求的行为序列操作符提供了这种协调功能的结构。 通过将任何异步 API 请求与 Future 发布者进行封装然后将其与 flatMap 操作符链接在一起你可以以特定顺序调用被封装的异步 API 请求。 通过使用 Future 或其他发布者创建多个管道使用 zip 操作符将它们合并之后等待管道完成通过这种方法可以创建多个并行的异步请求。 如果你想强制一个 Future 发布者直到另一个发布者完成之后才被调用你可以把 future 发布者创建在 flatMap 的闭包中这样它就会等待有值被传入 flatMap 操作符之后才会被创建。 通过组合这些技术可以创建任何并行或串行任务的结构。 如果后面的任务需要较早任务的数据这种协调异步请求的技术会特别有效。 在这些情况下所需的数据结果可以直接通过管道传输。 此排序的示例如下。 在此示例中按钮在完成时会高亮显示按钮的排列顺序是特意用来显示操作顺序的。 整个序列由单独的按钮操作触发该操作还会重置所有按钮的状态如果序列中有尚未完成的任务则都将被取消。 在此示例中异步 API 请求会在随机的时间之后完成作为例子来展示时序的工作原理。 创建的工作流分步表示如下 步骤 1 先运行。步骤 2 有三个并行的任务在步骤 1 完成之后运行。步骤 3 等步骤 2 的三个任务全部完成之后再开始执行。步骤 4 在步骤 3 完成之后开始执行。 此外还有一个 activity indicator 被触发以便在序列开始时开始动画在第 4 步完成时停止。 UIKit-Combine/AsyncCoordinatorViewController.swift import UIKit import Combineclass AsyncCoordinatorViewController: UIViewController {IBOutlet weak var startButton: UIButton!IBOutlet weak var step1_button: UIButton!IBOutlet weak var step2_1_button: UIButton!IBOutlet weak var step2_2_button: UIButton!IBOutlet weak var step2_3_button: UIButton!IBOutlet weak var step3_button: UIButton!IBOutlet weak var step4_button: UIButton!IBOutlet weak var activityIndicator: UIActivityIndicatorView!var cancellable: AnyCancellable?var coordinatedPipeline: AnyPublisherBool, Error?IBAction func doit(_ sender: Any) {runItAll()}func runItAll() {if self.cancellable ! nil { // 1print(Cancelling existing run)cancellable?.cancel()self.activityIndicator.stopAnimating()}print(resetting all the steps)self.resetAllSteps() // 2// driving it by attaching it to .sinkself.activityIndicator.startAnimating() // 3print(attaching a new sink to start things going)self.cancellable coordinatedPipeline? // 4.print().sink(receiveCompletion: { completion inprint(.sink() received the completion: , String(describing: completion))self.activityIndicator.stopAnimating()}, receiveValue: { value inprint(.sink() received value: , value)})}// MARK: - helper pieces that would normally be in other files// this emulates an async API call with a completion callback// it does nothing other than wait and ultimately return with a boolean valuefunc randomAsyncAPI(completion completionBlock: escaping ((Bool, Error?) - Void)) {DispatchQueue.global(qos: .background).async {sleep(.random(in: 1...4))completionBlock(true, nil)}}/// Creates and returns pipeline that uses a Future to wrap randomAsyncAPI/// and then updates a UIButton to represent the completion of the async/// work before returning a boolean True./// - Parameter button: button to be updatedfunc createFuturePublisher(button: UIButton) - AnyPublisherBool, Error { // 5return FutureBool, Error { promise inself.randomAsyncAPI() { (result, err) inif let err err {promise(.failure(err))} else {promise(.success(result))}}}.receive(on: RunLoop.main)// so that we can update UI elements to show the completion// of this step.map { inValue - Bool in // 6// intentionally side effecting here to show progress of pipelineself.markStepDone(button: button)return true}.eraseToAnyPublisher()}/// highlights a button and changes the background color to green/// - Parameter button: reference to button being updatedfunc markStepDone(button: UIButton) {button.backgroundColor .systemGreenbutton.isHighlighted true}func resetAllSteps() {for button in [self.step1_button, self.step2_1_button, self.step2_2_button, self.step2_3_button, self.step3_button, self.step4_button] {button?.backgroundColor .lightGraybutton?.isHighlighted false}self.activityIndicator.stopAnimating()}// MARK: - view setupoverride func viewDidLoad() {super.viewDidLoad()self.activityIndicator.stopAnimating()// Do any additional setup after loading the view.coordinatedPipeline createFuturePublisher(button: self.step1_button) // 7.flatMap { flatMapInValue - AnyPublisherBool, Error inlet step2_1 self.createFuturePublisher(button: self.step2_1_button)let step2_2 self.createFuturePublisher(button: self.step2_2_button)let step2_3 self.createFuturePublisher(button: self.step2_3_button)return Publishers.Zip3(step2_1, step2_2, step2_3).map { _ - Bool inreturn true}.eraseToAnyPublisher()}.flatMap { _ inreturn self.createFuturePublisher(button: self.step3_button)}.flatMap { _ inreturn self.createFuturePublisher(button: self.step4_button)}.eraseToAnyPublisher()} }runItAll 协调此工作流的进行它从检查当前是否正在执行开始。 如果是它会在当前的订阅者上调用 cancel()。resetAllSteps 通过遍历所有表示当前工作流状态的按钮并将它们重置为灰色和未高亮以回到初始状态。 它还验证 activity indicator 当前未处于动画中。然后我们开始执行请求首先开启 activity indicator 的旋转动画。使用 sink 创建订阅者并存储对工作流的引用。 被订阅的发布者是在该函数外创建的允许被多次复用。 管道中的 print 操作符用于调试在触发管道时在控制台显示输出。每个步骤都由 Future 发布者紧跟管道构建而成然后立即由管道操作符切换到主线程然后更新 UIButton 的背景色以显示该步骤已完成。 这封装在 createFuturePublisher 的调用中使用 eraseToAnyPublisher 以简化返回的类型。map 操作符用于创建并更新 UIButton作为特定的效果以显示步骤已完成。创建整个管道及其串行和并行任务结构是结合了对 createFuturePublisher 的调用以及对 flatMap 和 zip 操作符的使用共同完成的。 另请参阅 通过包装基于 delegate 的 API 创建重复发布者使用此代码的 ViewController 在 github 的项目中 UIKit-Combine/AsyncCoordinatorViewController.swift. 参考 https://heckj.github.io/swiftui-notes/index_zh-CN.html 代码 https://github.com/heckj/swiftui-notes
http://www.hkea.cn/news/14498808/

相关文章:

  • 想攻击一个网站怎么做湖南常德地图
  • 怎么样增加网站权重网推地推
  • 阿里云里做网站能上百度首页么app开发哪家好公司
  • 专门做门的网站域名一个注册要多久
  • 建设网站要准备什么17模板网站
  • 做二维码报名网站建站如何挣钱
  • 沈阳seo网站关键词优化优化平台建设公司
  • 哪里有做网站系统的直通车推广怎么收费
  • 滕州网站建设招聘seo1视频发布会
  • 如何评价网站是否做的好处网页设计心得体会300字
  • WordPress国产企业主题m东莞网站优化专家
  • 站长工具端口检测seo搜索优化是什么呢
  • 杭州高端网站购买空间网站哪个好
  • 建设局网站新闻购物网站建设规划书
  • 做网站 域名 最快要多久软装设计图 效果图
  • 3合一网站怎么做wordpress 树形页面
  • 定制鞋子的app企业优化推广
  • 专业做网站团队网站提示危险网站
  • html怎么做网站首页网络定制营销
  • 东莞网站关键词优化收费广西城乡建设部网站首页
  • 织梦网站后台空白做钢材的网站有哪些
  • 网站编程是什么意思网页游戏新游戏
  • 广州专业网站改版方案自驾游网站建设方案
  • 用div做网站中间部分做淘宝网站用什么软件有哪些
  • 自己建的网站可以用笔记本做服务器吗安徽建设厅网站考勤
  • 临沂网站网站建设流程精英
  • 哪里有网站开发公司品牌网站部门建设
  • 专业提供深圳网站设计公司现货交易平台合法吗
  • 建工网校官网登录入口谷歌seo怎么提高网站权重
  • 商务网站的可行性分析包括怎么搭建自己的网站挣钱