This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# RxJava ハンズオン | |
--- | |
# RxJavaとは | |
Reactive Extension for Java | |
https://github.com/ReactiveX/RxJava (Star 20000 以上) | |
イベントを作り、こねこねして、購読する |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class HogeFragment: Fragment, Screen { | |
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | |
super.onViewCreated(view, savedInstanceState) | |
hogeButton.setOnClickListener { navigate(Event.HogeOkClicked()) } | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 項目13 "<=>"とComparableモジュールで比較を実装しよう | |
class Version | |
include(Comparable) # <=>が定義されていれば、 <, <=, =>, > といったComparableで定義されたメソッドが利用可能になる | |
attr_reader :major, :minor, :patch | |
alias_method(:eql?, :==) # Hashのキーの同一性にeql?とhashを使う | |
def initialize(version) | |
@major, @minor, @patch = version.split('.').map(&:to_i) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://magazine.rubyist.net/articles/0046/0046-SingletonClassForBeginners.html | |
# https://docs.ruby-lang.org/ja/2.1.0/doc/spec=2fdef.html#class_method | |
# クラス定義 | |
class Hoge | |
def Hoge.foo | |
p "foo" | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://qiita.com/creamysellotape/items/68a7203bae7296707d43#comment-29e1991a2d2263d466ef | |
# 「メソッド実行中は常に自分自身(メソッドが呼び出されたインスタンス)が 誰であるかという情報が保存されており、selfでその情報を取ることができる。」 | |
# Class.new で渡されるブロックの引数はnewで生成するクラスになる https://docs.ruby-lang.org/ja/latest/method/Class/s/new.html | |
# トップレベルの文脈 | |
p self #=> main | |
class Foo | |
# クラス定義の文脈 | |
p self #=> Foo |