aboutsummaryrefslogtreecommitdiffstats
path: root/core/base/io.moon
blob: cbb5823a6413eade05f26d9f53e4f7ca39cf8767 (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
----
-- Incoming side-effect adapter, creating events for the dataflow graph.
--
-- Polled by the main event loop to kick of events that cause the the dataflow
-- graph to ripple results.
--
-- @classmod IO

class IO
--- IO interface.
--
-- methods that have to be implemented by `IO` implementations.
-- @section interface

  --- construct a new instance.
  --
  -- Must prepare the instance for `dirty` to be called.
  -- @classmethod
  new: =>

  --- poll for changes.
  --
  -- Called every frame by the main event loop to update internal state.
  tick: =>

  --- 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
  -- times. May be called before `tick` on the first frame after construction.
  --
  -- @treturn bool whether processing is required
  dirty: =>

  __tostring: => "<IO #{@@__name}>"
  __inherited: (cls) => cls.__base.__tostring = @__tostring

{
  :IO
}