diff --git a/README.md b/README.md index f124917..935dab5 100644 --- a/README.md +++ b/README.md @@ -95,7 +95,7 @@ First you define your state: ``` int? currentThreshold; -List currentUnfilteredItems; +var currentUnfilteredItems = []; ``` Followed by setting up listeners: @@ -116,6 +116,7 @@ And your state computation logic: ``` void updateDB() { + if (currentThreshold == null) return ; final filteredItems = currentUnfilteredItems. filter((x) => x > currentThreshold). toList(); @@ -196,7 +197,7 @@ final sum = Computed.withPrev((prev) { - A: Short answer is: you can't. The functions passed to Computed should be pure computations, free of side effects. If you are meaning to use an external value as part of the computation, see `.use`. If you want to react to a stream of external events, see `.react`. If you wish to produce external side effects, see `.listen` or `.as[Broadcast]Stream`. - Q: Why am I getting `Computed expressions must be purely functional. Please use listeners for side effects.` -- A: On debug mode, Computed runs the given computations twice to make sure they behave identically. If this does not hold, it throws this assertion. Possible reasons include mutating and using a mutable value inside the computation or returning a type which does not implement deep comparisons, like `List` or `Set`. +- A: On debug mode, Computed runs the given computations twice and checks if both calls return the same value. If this does not hold, it throws this assertion. Possible reasons include mutating and using a mutable value inside the computation or returning a type which does not implement deep comparisons, like `List` or `Set`. ## Pitfalls