Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

airframe-rx: Add RxOption[A] #1214

Merged
merged 14 commits into from
Aug 11, 2020
Merged

airframe-rx: Add RxOption[A] #1214

merged 14 commits into from
Aug 11, 2020

Conversation

xerial
Copy link
Member

@xerial xerial commented Aug 8, 2020

This is for simplifying Rx[Option[A]] handling. Currently, we need to nest multiple map calls:

val a = Rx.variable(Some("hello")) 
a.map { opt =>
   opt.map { x => div(s"message: ${x}") }
} // Rx[Option[RxElement]]

This code will be simpler like:

val a: RxOptionVar[A] = Rx.optionVariable(Some("hello"))
a.map { x => div(s" message: ${x}") } // Rx[Option[RxElement]]

a := Some("new value")

This PR also supports Rx[A].toOption if A is Option[_] type

This also closes #1200

@codecov
Copy link

codecov bot commented Aug 8, 2020

Codecov Report

Merging #1214 into master will decrease coverage by 0.00%.
The diff coverage is 89.09%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1214      +/-   ##
==========================================
- Coverage   83.20%   83.19%   -0.01%     
==========================================
  Files         289      291       +2     
  Lines       11042    11073      +31     
  Branches      732      713      -19     
==========================================
+ Hits         9187     9212      +25     
- Misses       1855     1861       +6     
Impacted Files Coverage Δ
...c/main/scala/wvlet/airframe/http/rx/RxOption.scala 72.22% <72.22%> (ø)
...-rx/src/main/scala/wvlet/airframe/http/rx/Rx.scala 97.43% <94.44%> (-2.57%) ⬇️
.../src/main/scala/wvlet/airframe/http/rx/RxVar.scala 100.00% <100.00%> (ø)
...shared/src/main/scala/wvlet/log/io/StopWatch.scala 80.20% <0.00%> (+0.20%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dcadd43...c06798a. Read the comment docs.

@xerial xerial requested a review from a team August 8, 2020 23:29
@xerial
Copy link
Member Author

xerial commented Aug 11, 2020

@shimamoto Let me merge this PR as it's becoming a blocker for supporting gRPC streaming #1226 #1227

@xerial xerial merged commit d08ea45 into wvlet:master Aug 11, 2020
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NPE at RxVar.update in Scala.js
1 participant