-
-
Notifications
You must be signed in to change notification settings - Fork 35
/
init.lua
81 lines (62 loc) · 1.97 KB
/
init.lua
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
--[=[
@class Matter
Matter. It's what everything is made out of.
]=]
--[=[
@within Matter
@prop World World
]=]
--[=[
@within Matter
@prop Loop Loop
]=]
--[=[
@within Matter
@prop Debugger Debugger
]=]
--[=[
@within Matter
@prop None None
A value should be interpreted as nil when merging dictionaries.
`Matter.None` is used by [`Component:patch`](/api/Component#patch).
]=]
--[=[
@within Matter
@function component
@param name? string -- Optional name for debugging purposes
@param defaultData? {} -- Default data that will be merged with data passed to the component when created
@return Component -- Your new type of component
Creates a new type of component. Call the component as a function to create an instance of that component.
If `defaultData` is specified, it will be merged with data passed to the component when the component instance is
created. Note that this is not *fallback* data: if you later remove a field from a component instance that is
specified in the default data, it won't fall back to the value specified in default data.
```lua
-- Component:
local MyComponent = Matter.component("My component")
-- component instance:
local myComponentInstance = MyComponent({
some = "data"
})
```
]=]
local immutable = require(script.immutable)
local World = require(script.World)
local Loop = require(script.Loop)
local newComponent = require(script.component).newComponent
local topoRuntime = require(script.topoRuntime)
export type World = typeof(World.new())
export type Loop = typeof(Loop.new())
return table.freeze({
World = World,
Loop = Loop,
component = newComponent,
useEvent = require(script.hooks.useEvent),
useDeltaTime = require(script.hooks.useDeltaTime),
useThrottle = require(script.hooks.useThrottle),
log = require(script.hooks.log),
useHookState = topoRuntime.useHookState,
useCurrentSystem = topoRuntime.useCurrentSystem,
merge = immutable.merge,
None = immutable.None,
Debugger = require(script.debugger.debugger),
})