Skip to content

sayhisam1/Ropost

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ropost

A Roblox lua implementation of postal.js (https://github.com/postaljs/postal.js) The goal is to simplify client-server communication into a publish/subscribe model. No more worrying about individual remote events!

Usage

See postal.js for reference (https://github.com/postaljs/postal.js) Or see the source code for documented api

The core API is very simple:

    -- subscribes to a specific channel and topic
    -- call disconnector() to unsubscribe from the channel and topic
    local disconnector = Ropost.subscribe({
        channel = "foo", 
        topic = "bar", 
        callback = function(data, envelope)
            -- data is a table containing stuff passed by the publisher; 
            -- envelope contains metadata (see below for details)
            print("this is some callback")
        end})

    -- publishes to a channel and topic
    Ropost.publish({
        channel = "foo", 
        topic = "bar",
        data = {
            baz = "something",
            qux = 1337
        }
    })

For ease of use, the API also includes a "channel" object that removes the need to specify a channel:

    local channel = Ropost.channel("foo")
    channel:publish("bar", {
        baz = "something",
        qux = 1337
    })

    local disconnector = channel:subscribe("bar", function(data, envelope)
        print("this is some callback")
    end})

    -- unsubscribes all subscribed callbacks
    channel:destroy()

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages