Replica - Server to client state replication (Module)

this has got to be one of the biggest examples of pure delusion and glazing i think ive ever seen in my years on the devforum :sob: :sob: :sob:

i think your statement

And maybe switch to a language that isnt older then most of its developers…

speaks plenty about how your brain capacity is the same as a 5th grader

6 Likes

Can we have a feature where Calling OnSet() will be called immediately on the first time?

I have been writing it like this for the past few days. (Using Fusion for UI)
where I have to set the variable first, and connect on a onSet function
to capture changes.

replicaClient.OnNew("GameTimer", function(replica)
    --- Capture initial data
	self.currentDuration:set(replica.Data.duration)
	self.initialTick:set(replica.Data.initialTick)
	
	replica:OnSet({"duration"}, function(duration)
		self.currentDuration:set(duration)
	end)
	replica:OnSet({"initialTick"}, function(initialTick)
		self.initialTick:set(initialTick)
	end)
end)

Instead if we can have where OnSet() will be called immediately if it detects it existed already for the first time. So we can easily write it like this instead :smiley:

replicaClient.OnNew("GameTimer", function(replica)
	replica:OnSet({"duration"}, function(duration)
		self.currentDuration:set(duration)
	end)
	replica:OnSet({"initialTick"}, function(initialTick)
		self.initialTick:set(initialTick)
	end)
end)

Thank you!

2 Likes

Nah, I know a language can be very competent despite its age. And honestly your right. My statement is completely false haha.

However that doesn’t really erase the fact that Luau is not as good as languages that are the industry standard…

I really dont think insulting me did you any good, we are both developers.

I think your statement

speaks plenty about your incapacity to show understanding. And instead push forth your own agenda and defensive measures against your ‘victim’.

Good day btw

However that doesn’t really erase the fact that Luau is not as good as languages that are the industry standard…

luau is a very up to date and fast language and could very much be used widespread in the industry. its a good example of how to do a high level lang right.
want something even faster and still lua? luajit (one of the fastest languages btw)

speaks plenty about your incapacity to show understanding. And instead push forth your own agenda and defensive measures against your ‘victim’.

you’re gonna say this after admitting yourself your entire first statement was just pure glaze, you’re just filling the devforum with more meaningless bs

Replica allows you to call .OnNew() whenever you like. Also Replicas are passed by reference to .OnNew() listeners, so several .OnNew() listeners could receive the same reference to a single replica.

My personal idea behind implementing Replica is to instantiate objects whenever a new replica is received through .OnNew() and push any externally relevant changes of a Replica to signals (e.g. Object.HealthChanged) defined by the developer using a custom signal class.

As for your question about replica:OnChange() I don’t have any tips for you. :OnChange() simply provides all relevant data that was used to mutate any value in a replica.

Understood, glad to have confirmation that .onNew() can be used anywhere.
Not sure where I got that thought from which lead me down this road.

Thank you for making things all that much easier to develop games for the community.

can we call onchange events from server?

What is the replacement for ListenToRaw?

I completely understand. But I wasn’t referring to ONLY Luau. I was referring to the roblox engine as a whole.

I’m really enjoying Replica! Let us know if this ever gets published to wally please. I think someone already did it but I do not trust re-publishes not from the original creator (especially if I want to always have the most up-to-date version of the module).

I see there’s a “replication” key in a replica but its not typed in the type. whats the proper way to set the replication to a single player etc

nvm I see :Subscribe(player), thank you

Very neat going to try it out on some new projects. If you could please add it to Wally if possible.

best public resource released this year along with profilestore - thx loleris

2 Likes

Its nearly been 2 months @loleris any idea when the documentation will be finished? Thanks!!

3 Likes

Never used ReplicaService, so trying to understand this. So every time you’d set a Profile’s data, you’d also use replica:Set()?

Will you add server listeners to it?

Hello @loleris I’ve ran into an issue with Replica, client replica does not detect when a new entry is added while using OnSet(), is this intentional? Are we supposed to use :OnChange if we want to listen to new keys?


image

:OnSet() listens to a change for the specified path (path in :OnSet() and :Set() have to match) - it was not meant to detect changes to a list - at that point using OnChange is the solution.

2 Likes

What is better to tell data for client
remote events or this

This is an extremely powerful module for server-sided data that isn’t able to be easily replicated (profiles, large tables of data with pets, items, etc.) as well as global data that you want to keep in memory for performance (without instancing).

If you just want to show player cash, this isn’t for you. However, if you want to create an inventory system, and a cash display, kills display, just anything that requires a lot of different fields of data, this is 100% for you and is an amazing resource.