Giter Site home page Giter Site logo

publisher's Introduction

Publisher

What's this?

A example of Sinatra::Streaming
It serves SSEs in a channel/event schema

What can you do with it?

For starters, fire it up with thin start or foreman start.
Then open your SSE/websocket supporting browser (let's go with the latest version of chrome) and hit localhost:3000/test
You'll be in a page with an open EventSource listening to server sent events trough the channel testchannel and for the event testevent

So you can open your irb and:

require 'net/http'
uri = URI('http://localhost:3000/publish')
Net::HTTP.post_form(uri, 'channel' => 'testchannel', 'event' => 'testevent', 'data' => '<br> Hello there')

And look at that, your data is showing up at real-time on your browser

What's next?

Well, I'd love to put in some of my projects models something like notify_to_publisher and have my model send to Publisher its json representation on each create, update, or destroy. Hey! Those sound like events, right?
Let's say I have a Post model and by dropping notify_to_publisher on it, on each CRUD operation the model will send its own json to the server using the post channel on the create, update or delete events.
Yeah, I think that's what I'll do next.

publisher's People

Contributors

lacides avatar

Stargazers

Roberto Miranda avatar  avatar Guillermo Iguaran avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.