blob: 519ef061a18f00c096954c8d6bcbae6cf291a13c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
----
-- Continuous stream of values.
--
-- @classmod SigStream
import Result, __eq from require 'alv.result.base'
class SigStream extends Result
--- Result interface
--
-- `SigStream` implements the `Result` interface.
-- @section result
--- return whether this Result was changed in the current tick.
-- @treturn bool
dirty: => @updated == COPILOT.T
--- unwrap to the Lua type.
--
-- Asserts `@type == type` if `type` is given.
--
-- @tparam[opt] type.Type type the type to check for
-- @tparam[optchain] string msg message to throw if type don't match
-- @treturn any `value`
unwrap: (type, msg) =>
assert type == @type, msg or "#{@} is not a #{type}" if type
@value
--- create a mutable copy of this stream.
--
-- Used to insulate eval-cycles from each other.
--
-- @treturn SigStream
fork: =>
with @@ @type, @value
.updated = @updated
--- alias for `unwrap`.
__call: (...) => @unwrap ...
--- the type of this Result's value.
-- @tfield type.Type type
--- the metatype string for this Result.
-- @tfield string metatype (`~`)
metatype: '~'
--- documentation metadata.
--
-- an optional table containing metadata for error messages and
-- documentation. The following keys are recognized:
--
-- - `name`: optional name
-- - `summary`: single-line description (markdown)
-- - `examples`: optional list of single-line code examples
-- - `description`: optional full-text description (markdown)
--
-- @tfield ?table meta
--- members
-- @section members
--- update this stream's value.
--
-- Marks this stream as dirty for the remainder of the current tick.
set: (value) =>
if not @type\eq value, @value
@value = value
@updated = COPILOT.T
--- the wrapped Lua value.
-- @tfield any value
--- static functions
-- @section static
--- construct a new Constant.
--
-- @classmethod
-- @tparam string type the type name
-- @tparam ?any value the Lua value to be accessed through `unwrap`
new: (type, @value) => super type
:__eq
{
:SigStream
}
|