carbaj0
06/16/2024, 11:54 AMfun <T, A> Lens<T, List<A>>.index(state: T, predicate: (A) -> Boolean): Optional<T, A> =
this.getOrNull(state)?.let { this.compose(Index.list<A>().index(it.indexOfFirst(predicate))) } ?: Optional.void()
State.posts.index(state) { it.id == postId }.likes transform { it + 1 }
Youssef Shoaib [MOD]
06/16/2024, 12:03 PM