Node event emitter class

This will be a post on the node event emitter class for making custom events in nodejs. It can come in handy now and then to make my own custom events, and attach handers for them, I just need to know where and when to call the emit method in my code when a custom event happens. However maybe it would be best to learn by doing, and to do so it might be best to just jump ahead to the code examples here on the node event emitter class.
This is a nodejs core build in module that is in node itself, so no npm package of any kind needs to be installed to get started with this, you just need node itself.

Read More

Node websocket simple vanilla javaScript example

So you want to get break ground with a node websocket project, and so you want to write everything vanilla javaScript style? First things first, reconsider and just use a package such as websocket-node, trust me this one is going to be time consuming. If you still want to just put together a very simple web socket server, and client then this post is my take on doing so.

Again when it comes to using websockets in an actual project you are going to want to use a well supported npm package, there is allot to this, and handing the handshake, and frames is a little complicated. STill if you just want to make a simple node websocket project working just with the core nodejs modules, maybe this post will help you get started at least.

This post will contain a very simple web socket server, and a very basic web socket client in addition to a simple http server that serves the client system.

Read More

Node os module examples

So you might be wondering if there is a node built in way to access all kinds of data about the host operating system that your nodejs project is running on top of. Maybe you want to work out some logic where you want to handle things a little differently if the project is running on top of windows rather than Linux of another posix system.

Well there is the idea of using the child process module as a way to just go ahead and see if a command of one sort or another works or not and figure it out that way. However maybe the node os core module is what you would rather start with. This node build in module contains many properties and methods than are helpful for gaining at least some basic information about what you are dealing with.

Read More

Node promise basics and beyond

Looking back I have wrote a few posts on promises in nodejs, and a few when it comes to using them in javaScript in general. However I have not yet wrote a main post on node promise topics when working in a node environment only. So in this post I will be keeping the focus on just working with promises in a nodejs project.

From just starting out with the Promise constructor, and the using the promisify utility method to convert old callback style methods to methods that return promises.

It would also be nice to have one post where I go beyond just the basics of promises, and give some real solid examples that outline why they are great for handing a whole bunch of async tasks.

Read More

Vue canvas topics including getting started scaling and more

For today maybe it would be a smart move to write a post on using vuejs, and canvas elements in the template of vuejs instances. Oddly enough that is a rock I have not flipped over just yet as I continue to play around with vuejs as a way to go about making a client side javaScript project.

When it comes to the canvas element alone I have made a collection of canvas examples that I work on a little more now and then, and also expand with new examples on occasion. Canvas elements are great, they really are a part of fun and interesting javaScript and they can be used to do just about everything when it comes to web based games, and animation like projects. With my canvas examples though I am not using any kind of framework each time I create a new example. A lot of people seem to think that kind of approach is how to really go about learning how to use something. Maybe there is a degree of truth to that, but a price is payed for sure, projects will take a lot longer. So it is a nice break from doing everything from the ground up by making a few examples where I am using vuejs at least as a way to help keep things a little more structured, and save a bit of time maybe.

Vuejs is just a general front end framework, and the use of vuejs by itself might not be the best choice when it comes to getting up and running with canvas right away. However there are a number of ways of adding canvas support, or using a canvas library of one kind or another with vuejs. However in this post I will just be using vuejs alone, and starting to just play around with some canvas elements in the template.

In this post I will be starting out with just some very basic examples of vuejs, and using one or more canvas elements in the template. There are things like scaling, and getting the position of a mouse click that I think I should also cover while I am at it. I really like vuejs a lot compared to other modern front end frameworks, and I sure like canvas a whole lot to, so lets get to some examples where we are combining two totally awesome things like peanut butter and chocolate.

Read More