UniRx勉強会   reactive extensions inside(公開用)
Upcoming SlideShare
Loading in...5
×

Like this? Share it with your network

Share

UniRx勉強会 reactive extensions inside(公開用)

  • 58 views
Uploaded on

UniRxの小規模勉強会での資料です。

UniRxの小規模勉強会での資料です。

More in: Software
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
58
On Slideshare
57
From Embeds
1
Number of Embeds
1

Actions

Shares
Downloads
0
Comments
0
Likes
1

Embeds 1

https://twitter.com 1

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Reactive Extensions Inside? UniRx 勉強会 wilfrem
  • 2. 自己紹介 ハンドル名: wilfrem 普段はPHPerでサーバサイドやってます。 趣味プロはずっとC++/C# ここ数年はMono系をちょこちょこと。
  • 3. What’s Rx The Reactive Extensions (Rx) is a library for composing asynchronous and event-based programs using observable sequences and LINQ-style query operators. Using Rx, developers represent asynchronous data streams with Observables, query asynchronous data streams using LINQ operators, and parameterize the concurrency in the asynchronous data streams using Schedulers. Simply put, Rx = Observables + LINQ + Schedulers. わからん! Rx公式のBrief Introより
  • 4. というわけで Unity(C#3.0)むけに分かりやすくするよ!
  • 5. C#3.0(Unity)ユーザのための Reactive Extensions Inside UniRx 勉強会 wilfrem
  • 6. Rxは何のライブラリなのか? Reactive Extension(以下Rx)は • イベントを使ったプログラミング • 非同期プログラミング • メッセージパッシングプログラミング を扱いやすくするための便利ライブラリです Rx.NET以外にも、UniRx/RxJava/rx.js/RxCpp/RxCocoa/RxPy/RxPHP等の実装あり
  • 7. UnityでRx使う主な利点 Unity(ゲーム制作)でRxを使うと • Eventより高機能なRxを使える • イベントの複雑な処理を綺麗に書ける • 重たい処理で”ザ・ワールド” を防げる • 通信周りを書きやすくなる • 短いコードでバグを減らせる などなど
  • 8. つまり Rx is 神
  • 9. Rxの考え方入門
  • 10. Rxを使いこなすために Rxは素晴らしい便利なライブラリ しかし、使いこなすためには 背景にある共通した考え方の習得が必要
  • 11. C#におけるevent C#のイベントとは • イベントが発生したタイミングで • EventArgsと一緒にpushされる push push push push Event Event Event Event time Args Args Args Args
  • 12. メッセージパッシング メッセージパッシングとは • メッセージを送信すると • 購読側にメッセージがpushされる push push push push messa messa messa messa time ge ge ge ge
  • 13. 非同期処理 非同期処理とは • 処理を別スレッドに投げる • 処理が終わったら結果がcallbackされる callback 結果time 処理 投げ
  • 14. UnityのUpdate ゲームにおけるフレームのUpdateとは • 各フレームが開始したタイミングで • Update関数が呼び出される time call call call call
  • 15. push Eve nt Args callbac k 結 果 time call call call call つまり time push Eve nt Args push Eve nt Args push Eve nt Args 処 理 投 げ time Event/ メッセージ 非同期 Update すべてが「時間」というシーケンス上の「要素」となる
  • 16. シーケンス化の利点? 我々Unity使いは、すでに知っている。 C#には 「LINQ」があることを (注1) ハイラルの勇者ではありません (注2) アイドルグループでもありません
  • 17. LINQとは 端的に言えば イテレータ(IEnumerable<T>)=シーケンスを • フィルタ • 合成 • 射影 などなど、イテレータをこねこねできる機能 Rxはこれを時間軸シーケンスに拡張する!
  • 18. つまりRxとは 端的に言えば 時間軸シーケンス(IObservable<T>)を • フィルタ • 合成 • 射影 などなど、時間軸をこねこねできる機能 +便利な機能が付いたライブラリである
  • 19. Rxの便利機能一覧 • IObservableのの合成・フィルタ・射影 • スケジューラー機能 • Subject<T> • 時間系機能 • 遅延やバッファ • Cold/Hot • Event→IObservable<T>変換 • (Unity向け)コルーチン→IObservable<T>変換 • (Unity向け)EveryUpdate() などなど https://github.com/neuecc/UniRx http://www.slideshare.net/okazuki0130/reactive-extensionsv01
  • 20. 機能比較
  • 21. Rx VS event • Rxが後発 • Rxもeventも、コールバック登録は同じ • 送付終了&エラーはeventには無い • eventにはフィルタや射影の機能は無い • Rxはdelegate定義要らない Eventの上位互換なので置き換えましょう。
  • 22. Rx VS async/await(Future) • RxはFutureパターンもできる。 – Task<T>=1個だけ値を返すIO<T> • Task<T>の利点 – ランタイム&コンパイラのサポート – ワーカスレッドの自動割り当て • Task<T>の欠点 – Unityではどう頑張っても使えない。
  • 23. 具体的に何を使うのか? 実際にどう使うのか? 今日の勉強会で実際にやってみましょう。
  • 24. ご清聴ありがとうございました