From f8d89aee2d5ce87380aaf3b985ae28759ff3abb9 Mon Sep 17 00:00:00 2001 From: s-ol Date: Sat, 4 Aug 2018 00:11:15 +0200 Subject: add \transform to reactivevar --- app/test_component.moon | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'app/test_component.moon') diff --git a/app/test_component.moon b/app/test_component.moon index 5298175..538368a 100644 --- a/app/test_component.moon +++ b/app/test_component.moon @@ -78,6 +78,21 @@ run_test "passed old value as well", -> reactive\set 3 assert done, "expected to reach the end" +run_test "provides transform shorthand", -> + local done + + reactive = ReactiveVar 1 + reactive\subscribe coroutine.wrap (next, last) -> + assert last == 1, "expected last:1 to be 1" + next, last = coroutine.yield! + assert last == 2, "expected last:2 to be 2" + done = true + + add_one = (a) -> a + 1 + reactive\transform add_one + reactive\transform add_one + assert done, "expected to reach the end" + run_test "#subscribe returns function to unsubscribe", -> calls = 0 -- cgit v1.2.3