网站综合信息 duan.ca
    • 标题:
    • Daniel Duan 
    • 关键字:
    •  
    • 描述:
    • Daniel Duan’s Thoughts And Works. 
    • 域名信息
    • 域名年龄:11年9个月17天  注册日期:2013年10月26日  到期时间:
      注册商:Name: PublicDomainRegistry.com Inc 
    • 备案信息
    • 备案号:未备案 
    网站收录SEO数据
    • 搜索引擎
    • 收录量
    • 反向链接
    • 其他
    • Google
    • 0  
    • 0  
    • pr:0  
    • 雅虎
    • 0  
    •  
    •  
    • 搜搜
    • 0  
    •  
    •  
    • 搜狗
    • 0  
    •  
    • 评级:0/10  
    • 360搜索
    • 0  
    •  
    •  
    域名流量Alexa排名
    •  
    • 一周平均
    • 一个月平均
    • 三个月平均
    • Alexa全球排名
    • -  
    • 平均日IP
    • 日总PV
    • 人均PV(PV/IP比例)
    • 反向链接
    • dmoz目录收录
    • -  
    • 流量走势图
    域名注册Whois信息

    duan.ca

    域名年龄: 11年9个月17天
    注册时间: 2013-10-26
    注 册 商: Name: PublicDomainRegistry.com Inc

    获取时间: 2013年10月26日 09:30:25
    Domain name: duan.ca
    Domain status: registered
    Creation date: 2013/04/04
    Expiry date: 2014/04/04
    Updated date: 2013/04/09

    Registrar:
    Name: PublicDomainRegistry.com Inc
    Number: 3059041

    Name servers:
    ns2.sedoparking.com
    ns1.sedoparking.com

    % WHOIS look-up made at 2013-10-26 01:32:35 (GMT)
    %
    % Use of CIRA's WHOIS service is governed by the Terms of Use in its Legal
    % Notice, available at http://www.cira.ca/legal-notice/?lang=en
    %
    % (c) 2013 Canadian Internet Registration Authority, (http://www.cira.ca/)
    同IP网站(同服务器)
    其他后缀域名
    • 顶级域名
    • 相关信息
    网站首页快照(纯文字版)
    抓取时间:2019年09月07日 17:52:27
    网址:http://duan.ca/
    标题:Daniel Duan
    关键字:
    描述:Daniel Duan’s Thoughts And Works.
    主体:
    Daniel Duan's blogarticlesvideosLinksProjectsAboutOn the Subject of Interface Hygiene01 Jul 2019|Combine,SwiftIn a purly reactive world, your entire program merge into a single stream. Now,close your eyes, and envision: your project as one, beautiful, stream.Now open your eyes. Yeah, it’s not. Your project is a Mac or iOS app. It’s fullof your memories, sweat, and blood. And you are ready to sweat and bleed somemore by putting some Combine and SwiftUI into it. You watched the WWDC19sessions and learned that “Subjcets are super powerful”. You looked into yourcode and realized you can’t really do anything with Combine without Subjectsat the current state of the project.Well…Here are a few habits that help keeping your project that prevasively usesCombine.Subject sane. They should seem obvious to anyone who understandsMurphy’s law and the value of minialism in interfaces. If you already are usingsome reactive stream implementation, substitute the types with theircounterparts in your framework and these rules should seem down right basic.Vend Subjects as PublishersSubjects help bridge from the imperitive to the reactive world. Somewhatparadoxically, sharing them is not very “RX-y”. This is akin to prefering letsover var.Most of the time, what you want to share is the values pumped into the stream,not the privilage to mutate it. Because Subjects conform to Publisher, it’seasy to hide from the users the fact that your stream is backed by them.// Bad: now anyone who get a hold of it can mess with your stream!public enum GreatInts {public var updates = CurrentValueSubject<Int, Never>(0)}With Combine this conversion happens via type-erasure:// Better: all your users care is the stream (publisher), so give them that!public enum GreatInts {// Internally, it's backed by a subject.var subject = CurrentValueSubject<Int, Never>(0)// Externally, it's just a Publisher. public var subject: AnyPublisher<Int, Never> {subject.eraseToAnyPublisher()}}CurrentValueSubject natually caches the latest valueRX theorists will hate this: sometimes it’s just practical to exposea synchronous interface to the latest vaule in the stream!Two things.It might be tempting to expose the subject and let your user use its.value. Well, you shouldn’t (as explained in the previous section).A separate interface dedicated to the latest value prevents people frompolluting your stream.// (Still) badpublic final class GreatInts {public var updates = CurrentValueSubject<Int, Never>(0)}Remember CurrentValueSubject has that .value property! It may seemsurprising, but I’ve seen folks transitioning to RX clinging to the old ways:public final class GreatInts {// well, at least it's not a public subject...var subject = CurrentValueSubject<Int, Never>(0) // <- initial value 0public var updates: AnyPublisher<Int, Never> {subject.eraseToAnyPublisher()}// Wait, there's that 0 againpublic var latest: Int = 0 {didSet {subject.send(latest) // ?}}}First, you’ll notice

    © 2010 - 2020 网站综合信息查询 同IP网站查询 相关类似网站查询 网站备案查询网站地图 最新查询 最近更新 优秀网站 热门网站 全部网站 同IP查询 备案查询

    2025-08-07 14:08, Process in 0.0465 second.