Code Monkey home page Code Monkey logo

gamesroom's Introduction

GamesRoom

pattern for template events using async-await

events({
	[`click`]: async function clickSomething(event, instance) {
		// note the use of 'async' keyword is required for 'await',
		// use a try-catch block to wrap every await, since every await may fail 
		try {
			// asyncPromiseFn is a prototype method on the various classes and returns a promise
			var result = await instance.data.item.asyncPromiseFn();  
			// var is used deliberately to be not scoped to within the try block
		} catch (e) {
			console.error(e)
		} finally {
			// clean up
		}
		console.log(result)
		// other stuff
	},
	[`click .another`]: async function clickAnother(event, instance) {
		try {
			// Promise.all / Promise.race can be used
			var [result1, result2] = await Promise.all([instance.data.item.asyncPromiseFn(), anotherPromise()]);  
			// var is used deliberately to be not scoped to within the try block
		} catch (e) {
			console.error(e)
		} finally {
			// clean up
		}
		console.log(result1, result2)
		// other stuff
	},
});

TODO:

  • create define methods for chat class
  • split chat & message js file
  • create client-side class for chat
  • add publication for chat
  • add collection as part of class static variable
  • add unblock to method calls
  • add documentation for chat-server package
  • add documentation for chat-client package
  • add documentation for message package
  • split Chat and Message package
  • test chat package
  • create define methods for room class
  • create client-side class for room
  • add documentation for room package
  • test room package
  • create players/users package
  • update Chat tests when players/users package is written
  • add client-side collection for simulation
  • consider add lodash

gamesroom's People

Contributors

peonmodel avatar

Stargazers

 avatar

Watchers

 avatar  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.