Git Product home page Git Product logo

Comments (2)

hagsteel avatar hagsteel commented on September 22, 2024

It is not possible to use other types of serializer with SwampDragon, as the serializers act in a very particular way (just like DRF serializers won't work with Django's default serializers).

You can however push data to the browser without involving the serializers at all.

If you want to push data to the browser, simply setup a router, subscribe the client (the browser) to a channel, and you can push data.

The chat example does this without involving the models at all.
You have the router: https://github.com/jonashagstedt/swampdragon/blob/master/chat_example/chat_example/chat/routers.py

and the JS controller:
https://github.com/jonashagstedt/swampdragon/blob/master/chat_example/chat_example/static/js/chat-controllers.js

You don't have to use AngularJS if you don't want to, you can easily use vanilla JS (see http://swampdragon.net/documentation/javascript/ for documentation).

Once you have a client subscribed to a channel you don't even need to communicate with the client via the router, you can use the publish_data function.

In the aforementioned chat example, the client will subscribe to the chat channel.
After that you could, if you wanted to, publish data to that channel as such:

publish_data(channel='chat', data={'foo': 'bar'})

So in this case the serializers aren't used, no model publishing involved etc.

More information on publish_data

http://swampdragon.net/documentation/publishing-data/

from swampdragon.

wickkiey avatar wickkiey commented on September 22, 2024

This is great work. Just to add in the chat_example, mentioned JS controller(chat-controller.js) is not included but app.js.

And i tried with
publish_data(channel='local-channel',kwargs)

it is not working.

And with publish function it is working for all channel names. Can you please explain how to limit messages to specific channels in a same router...

from swampdragon.

Related Issues (20)

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.