Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我试图弄清楚如何在 Scala 中使用 Publisher.subscribe(Sub, Filter) 方法。如果我理解正确,我可以在那里指定订阅者通知哪些方法,哪些不通知?
有人愿意举例说明这种过滤器的语法吗?
请注意,Scaladoc 说:type Filter = (Evt) ⇒ Boolean. Evt因此,从to 的任何功能Boolean都可以,例如publisher.subscribe(this, _ != null).
type Filter = (Evt) ⇒ Boolean
Evt
Boolean
publisher.subscribe(this, _ != null)