1.0.3 • Published 2 years ago

@rbxts/messages v1.0.3

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

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)
1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago