@rbxts/message v0.0.1
Messages is a fast and light-weight library which lets you send and receive data between scripts across your game, not betweem different context levels though (server -> client or vice-versa).
I remade my old library with a more reliable version of it, which in this case has a better syntax and better typing over.
I not plan on adding further functionality if it isn't needed, it may become useless at long-term. The big advantage comes to receiving data, as not too many libraries (at least on roblox-ts) lets you do this for some reason.
Here are some examples and the best practices to use this small library!
/* Script 1 */
import { Messages } from "@rbxts/messages";
interface IConversation {
testing: (firstPart: string) => string
}
export const Conversation = Messages.createConversation<IConversation>()
/* Script 2 */
import Conversation from "..."
Conversation.testing.listen((firstPart: string) => {
return `${firstPart}, world!`
})
print(...Conversation.testing.send("Hello")); // -> Hello, world!
/**
* You can use the notation Conversation.testing() as well
* but for consistency and logic (because the module acts as
* if it was a conversation) it is RECOMMENDED to use .send().
We use ...[]
because the return it is taken as a LuaTuple. Though when you compile this example, is
ugly so don't try it this way. Anyway, an API isn't needed. But here is a list of all the available methods:
- .send()
- .listen()
- .stopListening()
- .listenAgain()
- .isListening()
And all the properties:
- listeners (an array of functions, which are the ones you binded)
Why is not an official release?
You may ask yourself, why is it 0.x version? Well, I haven't really made deep testing (unit testing, most likely with TestEZ) to say that is a full, bug-free release. If you encounter any problem, just let me know. siriuslatte#2024
2 years ago