Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

README.md

Latest commit

 

History

History
46 lines (36 loc) · 1.09 KB

README.md

File metadata and controls

46 lines (36 loc) · 1.09 KB

A alternative to NSNotificationCenter

Usage

// Automatically invalidate on release.varpipe:Pipe<String>?// Automatically invalidate on release.vartoken1:PipeSourceToken?vartoken2:PipeSourceToken?foo(){    pipe=Pipe<String>()    // Source1    token1= pipe?.sourceChannel.read{ valueinprint("source 1:\(value)")}DispatchQueue.main.asyncAfter(deadline:.now()+1){        // Broadcast a value.self.pipe?.sinkChannel.write("郑念真 520")                // Source2: Receive value on main queue, and replay latest value.        token2= pipe?.sourceChannel.read(onQueue:.main, replay:true){ valueinprint("source 2:\(value)")}DispatchQueue.main.asyncAfter(deadline:.now()+1){            // Manual invalidation, Source1 will not receive value again.self.token1?.invalidate()self.pipe?.sinkChannel.write("1314")self.pipe=nil}}}foo()// print// source 1: 郑念真 520// source 2: 郑念真 520// source 2: 1314

[8]ページ先頭

©2009-2025 Movatter.jp