Code Monkey home page Code Monkey logo

auction-frontend's People

Contributors

devibhattarai avatar dineshdb avatar rupesh1439 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

auction-frontend's Issues

Cleaning URL

Remove dependency on axios and remove hardcoded baseUrl.

WebSocket implementation

Currently we use websocket for live update. Websocket implementation of the browsers is used and on top of it we use STOMP protocol on top of websocket.

After we connect, we can subscribe on any path using,
client.subscribe(path, callback)
Callback is called whenever a message is received. Callback is a simple function.

Here we subscribe to individual path like /auction/:auctionid which creates a unique path for each auction and any info posted in this path is sent to us.

example,
function callback(event){ console.log(event.body)// simple message }

But we don't have information about which auction event this is, we can extract that information from path but we have better solution. Why not create a new function which has auctionid as argument and returns a new function that will be called by the subscribe method.

function callbackCreator(auctionID){
    // we can do anything here with auctionID
    // let's create a new function that uses this id
    function callback(event){
        console.log(event, auctionID) // we can use both. But this function is not called.
    }
    // Lets call this callback
    callback("adfasd");
   // But it should be called by the subscribe method. so let's return this function as is.
    return callback // function is returned.
}

// Now lets get the function returned by above method
let callback = callBackCreator(12)

//and pass it to subscribe method.
client.subscribe("/auction/1", callback)
// or even better
client.subscribe("/auction/1", callbackCreator(1))

But why not make it generic over auctionID?

function auctionSubscriber(id){
    client.subscribe("/auction/" + id, callBackCreator(id))
}

That's it.

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.