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

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

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

Presented at Bonfire iOS #4

cockscomb

May 15, 2018
Tweet

More Decks by cockscomb

Other Decks in Programming

Transcript

  1.  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ؔ࿈
   ৽ϑϨʔϜϫʔΫͱΞοϓσʔτ Ӭ໺఩ٱ 
  2. %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?) }
  3. 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> ) }
  4. 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, ); } }