aboutsummaryrefslogtreecommitdiffstats
path: root/core/stream
diff options
context:
space:
mode:
authors-ol <s-ol@users.noreply.github.com>2020-03-25 10:43:29 +0000
committers-ol <s-ol@users.noreply.github.com>2020-03-25 11:25:05 +0000
commit7cb862f6f6079509dafd466fff83c719cb2fd89e (patch)
tree843f92c4d4b2507e88a525b7c56c29d343958e5b /core/stream
parentValue -> Value/Event/IO-Stream (diff)
downloadalive-7cb862f6f6079509dafd466fff83c719cb2fd89e.tar.gz
alive-7cb862f6f6079509dafd466fff83c719cb2fd89e.zip
new core.base.match, update lib
Diffstat (limited to 'core/stream')
-rw-r--r--core/stream/base.moon11
-rw-r--r--core/stream/event.moon12
-rw-r--r--core/stream/io.moon9
-rw-r--r--core/stream/value.moon14
4 files changed, 32 insertions, 14 deletions
diff --git a/core/stream/base.moon b/core/stream/base.moon
index ee4ee17..cdccdc2 100644
--- a/core/stream/base.moon
+++ b/core/stream/base.moon
@@ -53,17 +53,6 @@ class Stream
--
-- @tfield ?table meta
- __tostring: =>
- value = if @meta.name
- @meta.name
- else if 'table' == (type @value) and rawget @value, '__base'
- @value.__name
- else
- tostring @value
- "<#{@@__name} #{@type}: #{value}>"
-
- __inherited: (cls) => cls.__base.__tostring = @__tostring
-
--- static functions
-- @section static
diff --git a/core/stream/event.moon b/core/stream/event.moon
index 5dbf846..f7b49c4 100644
--- a/core/stream/event.moon
+++ b/core/stream/event.moon
@@ -26,7 +26,7 @@ class EventStream extends Stream
@events = {}
@updated = registry.Registry.active!.tick
- table.insert @events, {}
+ table.insert @events, event
--- get the sequence of current events (if any).
--
@@ -45,11 +45,19 @@ class EventStream extends Stream
-- Used to wrap insulate eval-cycles from each other.
--
-- @treturn EventStream
- fork: => EventStream @type
+ fork: => @@ @type
--- alias for `unwrap`.
__call: (...) => @unwrap ...
+ __tostring: =>
+ "<#{@@__name} #{@type}>"
+
+ --- Stream metatype.
+ --
+ -- @tfield string metatype
+ metatype: 'event'
+
--- the type name of the stream.
--
-- the following builtin typenames are used:
diff --git a/core/stream/io.moon b/core/stream/io.moon
index fcaeb9f..e3e59a2 100644
--- a/core/stream/io.moon
+++ b/core/stream/io.moon
@@ -24,6 +24,13 @@ class IOStream extends EventStream
-- @tparam string type the typename of this stream.
new: (type) => super type
+ --- create a mutable copy of this stream.
+ --
+ -- Used to wrap insulate eval-cycles from each other.
+ --
+ -- @treturn IOStream
+ fork: => @
+
--- poll for changes.
--
-- Called every frame by the main event loop to update internal state.
@@ -32,7 +39,7 @@ class IOStream extends EventStream
--- check whether this adapter requires processing.
--
-- Must return a boolean indicating whether `Op`s that refer to this instance
- -- via `Input.io` should be notified (via `Op:tick`). May be called multiple
+ -- via `Input.hot` should be notified (via `Op:tick`). May be called multiple
-- times. May be called before `tick` on the first frame after construction.
--
-- If this is not overrided, the `EventStream` interface can be used, see
diff --git a/core/stream/value.moon b/core/stream/value.moon
index 0220f06..ce3ffc7 100644
--- a/core/stream/value.moon
+++ b/core/stream/value.moon
@@ -57,6 +57,20 @@ class ValueStream extends Stream
-- Compares two `ValueStream`s by comparing their types and their Lua values.
__eq: (other) => other.type == @type and other.value == @value
+ __tostring: =>
+ value = if @meta.name
+ @meta.name
+ else if 'table' == (type @value) and rawget @value, '__base'
+ @value.__name
+ else
+ tostring @value
+ "<#{@@__name} #{@type}: #{value}>"
+
+ --- Stream metatype.
+ --
+ -- @tfield string metatype
+ metatype: 'value'
+
--- the type name of this stream.
--
-- the following builtin typenames are used: