Author: sanqunbao

Html

Dojo Tutorial: Layout with Dijit

Next in our ongoing series of Dojo Tutorials, we’ll tell you about Layout with Dijit. Bring your layouts to life Creating dynamic and interactive layouts is a challenge common to any graphical user interface. We have a lot of ability to create layout with HTML and CSS. Where CSS leaves off, Dojo picks up with […]

TypeScript

Setting Up a New TypeScript Project

It’s easy to work with TypeScript when using a starter project or a tool like the Angular CLI, but what about a simple TypeScript project that would otherwise be just a vanilla JavaScript project? Let’s go over some simple ways to get started. Dependencies First, you need TypeScript installed of course. You can decide to […]

Html

Dojo Object Stores

Dojo 1.6 introduces a new data store API called Dojo Object Store. This new store API is based on the HTML5 IndexedDB object store API and is designed to greatly simplify and ease the interaction and construction of Dojo stores. Update: dstore is developing as a successor to Dojo object stores, so if you are […]

TypeScript

Introduction to Enums in TypeScript

Enums are a TypeScipt data type that allow the organization of number-based collections of unique identifiers. Here’s how to define a simple enum: enum Transport { train, bus, bike, car } let myTransport = Transport.bus; console.log(myTransport); // 1 You can access an enum value by it’s number value or by the string that’s associated with […]

TypeScript

Introduction to Interfaces in TypeScript

TypeScript helps us keep a contract with our vales by allowing us to define fine-grained type checking for them. Interfaces is the primary mechanism in TypeScript to accomplish that. Let’s say for example that we have the following code where we define two users: const user1 = { id: 1, firstName: ‘John’, lastName: ‘Doe’, proUser: […]

TypeScript

Object Rest and Spread in TypeScript

TypeScript 2.1 brings us object rest & spread to easily destructure, make shallow copies and merge objects into new ones. Object Spread Create shallow copy of objects: const names = {cat: ‘Bob’, dog: ‘Fred’, alligator: ‘Benedict’}; const newNames = { …names }; console.log(newNames.cat); // Bob You can merge multiple objects into a new object: const […]

TypeScript

String Literal Types in TypeScript

In TypeScript, string literal types let you define types that only accept a defined string literal. They are useful to limit the possible string values of variables. It’s better explained with short code samples, so here are examples of how to define and use string literal types: let pet: ‘cat’; pet = ‘cat’; // Ok […]

TypeScript

Union Types in TypeScript

In TypeScript you can use union types to describe values that can be of more than one type. It therefore allows to avoid using any. Define union types with the | character to separate the different possible types. For example, let’s say a function definition uses parameters that describe values that can be either strings […]