Upgrade to Pro — share decks privately, control downloads, hide ads and more …

ユーザインターフェイスと非同期処理

 ユーザインターフェイスと非同期処理

Presented at Bonfire iOS #4

58b40ae3b0db6cf0202a3802e9dd70fe?s=128

cockscomb

May 15, 2018
Tweet

Transcript

  1. ϢʔβΠϯλʔϑΣΠεͱ
 ඇಉظॲཧ

  2. id:cockscomb Ճ౻ਘथ גࣜձࣾ͸ͯͳ γχΞΞϓϦέʔγϣϯΤϯδχΞ

  3. ࡢࠓ w (PPHMF*0͸Ͳ͏Ͱ͔ͨ͠ʁ w 88%$͕͍͖ۙͮͯ·ͨ͠Ͷ w ͳʹ͕ൃද͞ΕΔָ͔͠ΈͰ͢Ͷ w Έͳ͞Μ͸ͲΜͳظ଴Λ͍࣋ͬͯ·͔͢ʁ w

    88%$͸Ͳ͏Ͱ͚ͨͬ͠
  4. J04 w "3,JU΍$PSF.- w 6*,JU w %SBHBOE%SPQ w 'JMFT

  5.  J04ͷ֓ཁ Ӭ໺఩ٱ   "3,JU అमҰ   $PSF.-

    ٢ా༔Ұ   4XJGUͷ৽ػೳͱΞοϓσʔτ ஑ాᠳ   9DPEFͷ৽ػೳ ࡔాߊҰ   %SBHBOE%SPQ Ճ౻ਘथ   'JMFTͱ%PDVNFOU#BTFE"QQMJDBUJPO Ճ౻ਘथ   6*,JUͷΨΠυϥΠϯͷมߋ఺ͱ
   "VUP-BZPVUͷ৽ػೳɺΞοϓσʔτ઒ᬒ༤հ   $PSF/'$ ؛઒ࠀݾ   1%',JU ؛઒ࠀݾ   4JSJ,JU ؛઒ࠀݾ   )PNF,JUೖ໳ͱJ04ʹ͓͚Δ৽ػೳ ॴ༑ଠ   .FUBM అमҰ   "VEJP.FEJBؔ࿈
   ৽ϑϨʔϜϫʔΫͱΞοϓσʔτ Ӭ໺఩ٱ 
  6. 63-4FTTJPO5BTL open class URLSessionTask : NSObject, NSCopying, ProgressReporting { @available(iOS

    11.0, *) open var progress: Progress { get } }
  7. public protocol ProgressReporting : NSObjectProtocol { public var progress: Progress

    { get } }
  8. %SBHBOE%SPQ open class NSItemProvider : NSObject, NSCopying { @available(iOS 11.0,

    *) open func registerDataRepresentation(forTypeIdentifier typeIdentifier: String, visibility: NSItemProviderRepresentationVisibility, loadHandler: @escaping ((Data?, Error?) -> Swift.Void) -> Progress?) }
  9. None
  10. 1SPHSFTT3FQPSUJOH w ඇಉظॲཧͷঢ়گΛϢʔβΠϯλʔϑΣΠεʹ൓өͰ͖Δ w "DUJWJUZ*OEJDBUPS΍1SPHSFTT#BSΛදࣔ͢ΔͱΑ͍ w l)VNBO*OUFSGBDF(VJEFMJOFTr1SPHSFTT*OEJDBUPSTzΑΓ w ݱࡏͷ3Y4XJGUͰѻ͏ͷ͸೉͍͠

  11. <2>ͳͥඇಉظʹ͢Δͷʁ

  12. None
  13. <2>ͳͥඇಉظʹ͢Δͷʁ ϝΠϯεϨουͷ3VO-PPQΛࢭΊͨ͘ͳ͍͔Β ࢭΊͯ͠·͏ͱΧΫΧΫ͢Δ

  14. <2>ΈΜͳ͸Ͳ͏ͯ͠Δʁ

  15. 3FBDUlTVTQFOTFz const movieDetailsFetcher = createFetcher( fetchMovieDetails ) const MovieDetails: React.SFC<MovieDetailsProps>

    = ({id}) => { const movie = movieDetailsFetcher.read(id) return ( <div className="MovieDetails"> <MoviePoster src={movie.poster} /> <h1>{movie.title}</h1> <MovieMetrics {...movie} /> </div> ) }
  16. 'MVUUFS w 3FBDUʹΠϯεύΠΞ w %BSUΛ࢖͏

  17. Future<AtomFeed> fetchAtom(String atomUrl) async { var atomXml = await http.read(atomUrl);

    return parse(atomXml); } class Feed extends StatelessWidget { final String url; const Feed({Key key, this.url}) : super(key: key); @override Widget build(BuildContext context) { var entries = new FutureBuilder<AtomFeed>( future: fetchAtom(url), builder: (context, snapshot) { if (snapshot.hasData) { var feed = snapshot.data; return new Entries(feed: feed); } else if (snapshot.hasError) { return new Text("${snapshot.error}"); } return new CircularProgressIndicator(); }); return new Scaffold( appBar: new AppBar(title: new Text("Feed")), body: entries, ); } }
  18. w એݴతͳ6*ϑϨʔϜϫʔΫ͕ྲྀߦ w 3FBDU 'MVUUFS w ඇಉظॲཧΛѻ͍΍͘͢͢Δ࢓૊Έ w 3FBDUͷTVTQFOTF w

    'MVUUFSͷ'VUVSF#VJMEFS w .BS[JQBO͸Ͳ͏ͳΔʁ
  19. .BS[JQBO w Ͳ͏͍͏΋ͷ͔ w 6*,JUͷҠ২ʁ w ৽͍͠6*ϑϨʔϜϫʔΫʁ w 4XJGUͱͷ਌࿨ੑ͸ w

    ͦ΋ͦ΋ൃද͞ΕΔͷ͔