Skip to content

Commit 94f43c2

Browse files
committed
5.0 migration
1 parent fc8a501 commit 94f43c2

File tree

1 file changed

+99
-0
lines changed

1 file changed

+99
-0
lines changed

docs/migration5.md

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
---
2+
title: 0.5.0 Migration
3+
---
4+
5+
# Migrating to 0.5.0
6+
7+
!!! note
8+
This migration guide is hosted here during the release candidate phases of
9+
development, but will be moved into the main documentation site once 0.5.0
10+
docs are fully baked.
11+
12+
## Fragment -> CatworkAsyncObject
13+
14+
Fragment has been renamed to CatworkAsyncObject, this has changed several APIs.
15+
This change was made to better reflect how these objects work, since the name
16+
`Fragment` is a leftover from the Tabby days.
17+
18+
### Constructing objects
19+
20+
This is simply a rename from `Catwork.Fragment` to `Catwork.new`, to construct
21+
objects from services, use the newly added `Service.CreateObject` method, which
22+
replaces `Service.Fragment`.
23+
24+
### Service Callbacks regarding CatworkAsyncObject
25+
26+
Service callbacks and methods have simply been renamed from `Fragment[X]` to
27+
`Object[X]`
28+
29+
These are:
30+
31+
* `Service.Fragment` -> `Service.Object`
32+
* `Service.CreateFragmentFromObject` -> `Service.CreateObjectFromClass`
33+
* See also; `Template -> Class`
34+
* `Service.FragmentAdded` -> `Service.ObjectAdded`
35+
* `Service.FragmentRemoved` -> `Service.ObjectRemoved`
36+
37+
## Template -> Class
38+
39+
Templates have been renamed to Classes, the only callback within services here
40+
that needs to be changed is `Service.Template` to `Service.Class`, its worth
41+
noting that this function has a different signature.
42+
43+
!!! info "Converting templates to classes"
44+
=== "Old Template Construction"
45+
46+
```lua
47+
return TemplateService:Template {
48+
Name = "Meowitzer",
49+
CreateFragment = function(fragment)
50+
function fragment:Init()
51+
print("meow!")
52+
end
53+
end
54+
}
55+
```
56+
57+
=== "New Class Construction"
58+
59+
```lua
60+
return TemplateService:Class("Meowitzer", function(object)
61+
function object:Init()
62+
print("meow!")
63+
end
64+
end)
65+
```
66+
67+
## Changes to `TimeoutDisabled` and similar keys
68+
69+
Catwork will now define these keys using the newly added `meta` function, this
70+
was done to better isolate internal Catwork keys.
71+
72+
!!! info "Old"
73+
=== "Old"
74+
75+
```lua
76+
return Catwork.Fragment {
77+
TimeoutDisabled = true
78+
}
79+
```
80+
81+
=== "New"
82+
83+
```lua
84+
return Catwork.new {
85+
[meta "TimeoutDisabled"] = true
86+
}
87+
```
88+
89+
All keys which have been converted to use the `meta` function are listed here
90+
91+
```
92+
EnableClasses
93+
TimeoutDisabled
94+
95+
# these are new metakeys but added here regardless
96+
AwaitFor
97+
EnableUpdating
98+
PluginMetadata
99+
```

0 commit comments

Comments
 (0)