Front-end for our auction project(3rd year Minor Project).
- Ashutosh Poudel [email protected]
- Dinesh Bhattarai [email protected]
- Jeevan Thaa [email protected]
- Rupesh Shrestha
Front-end for our auction project(3rd year Minor Project).
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.
Remove dependency on axios and remove hardcoded baseUrl.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.