DailyJS

Read Only References, Getting MEAN

Alex R. Young

Subscribe

@dailyjs

Facebook

Google+

books node harmony ES6

Read Only References, Getting MEAN

Posted by Alex R. Young on .
Featured

books node harmony ES6

Read Only References, Getting MEAN

Posted by Alex R. Young on .

Creating Read-Only References

I was working on an API where the desktop developers were worried I could break their code if my server had a typo in one of the API responses. The server was returning JSON objects, and some of the properties were important, so if they were spelled incorrectly it could be dangerous.

I wrote unit tests to ensure the API responses were the ones they expected, and used Object.defineProperty to make the API response properties read only. But what if you wanted some objects to have read/write access to an object, and others to be set as read only?

Sergey Bolshchikov sent in his post about this topic, called Creating Read-Only References. He suggests using Object.observe, so certain objets can subscribe to changes.

Object.observe is basically the future standard way to do databinding. Sergey mentions some polyfills for it, so you can use it in browsers.

Getting MEAN with Mongo, Express, Angular, and Node

Simon Holmes is writing a book about Mongo, Express, Angular, and Node. I've used exactly this cocktail of technologies for some of my commercial work over the last two years, but I'd never thought of the acronym MEAN before. The marketing spin is it's the new LAMP.

You can download the first chapter free, but the book is currently being written. If you buy it early you can contribute to its development by providing the author with feedback. The publisher calls this process MEAP (Manning Early Access Program).