-
Notifications
You must be signed in to change notification settings - Fork 2
sync
#sync - type modifier
Stability: 3 - Stable
the sync modifier automatically triggers the track modifier. so synced types are also tracked types.
synced instances will be synced over several frames.
you can pass a synced instance as parameter or return type of a frame function.
class type sync SyncedClass {
};
function frame "server" doStuff(SyncedClass param){
};
the return type of a frame function must be a promise of course.
class type sync SyncedClass {
};
function SyncedClass* frame "server" doStuff(){
};
when a instance gets passed from one frame to another it's made sure that they are kept in sync.
in essence you can think of it as one and the same instance.
Stability: 2 - Unstable
you can control which members are being synced. the value of a non synced member always depends on what the last assignment in the current frame was.
right now you can only control if you want to sync all members or non.
this syntax is subject to change.
to be sure your members are synced always use the following syntax. (for now)
class type sync all SyncedClass {
};
use instances between frames. implement your program logic across frames.
Stability: 0 - Idea
the alternative syntax will be sync some.
class type sync some SyncedClass {
};
while simply using the modifier sync without a parameter will default to one of the cases.
there will also be a way to mark members to be synced.
class type sync some SyncedClass {
member1 sync: "default",
member2: "default" // non synced
};
Stability: 3 - Stable
freely assigned members are never synced.
class type sync all SyncedClass {
member1: "default"
};
SyncedClass var1 = new SyncedClass();
var1.someMember = 1; // this is not gonna be synced.
non typed member functions can not be synced. typed member functions are being executed on every frame.
if you want to sync a member function that only uses var types add the return type to your function to make it typed
class type sync all SyncedClass {
function var memberFun(){
}
};
easily implement distributed events
Stability: 3 - Stable
there is one special pattern for synced instances that was worthy of getting its own implementation and keyword.
consider a server function producing instances, that are only used on the client.
class type sync all SyncedClass {
};
function *SyncedClass factory frame "server" (){
return new SyncedClass();
};
in this case the client can get instances from the server, but the instance will only continue to live on the client.
the server has lost all references to it, thats why its being destroyed on the server frame.
to avoid this you can add the serve keyword
class type sync serve all SyncedClass {
};
function *SyncedClass factory frame "server" (){
return new SyncedClass();
};
serve means the frame that created the instance will keep a reference alive until every (!) other connected frame, or frame connected by proxy has lost all references to it.
program a object server
continue reading about the unique modifier
found any errors?
missing something?
let me know