Skip to content

Instantly share code, notes, and snippets.

View ilyavf's full-sized avatar

Ilya ilyavf

View GitHub Profile
@ilyavf
ilyavf / min-data-req.md
Last active September 30, 2015 03:36
DoneJS Features - Minimal Data Requests

Caching and Minimal Data Requests

http://donejs.com/Features.html#section=section_Cachingandminimaldatarequests

Description:

DoneJS applications are able to do variety of performance improvements by intelligently managing the data layer.

One of the slowest actions for a web page is a network request. SPA tend to do a lot of AJAX calls asking server for necessary data. Latency is more noticeable during initial load of the application, but also if a lot of user actions on the page are accompanied by AJAX calls, user might soon get bored with loading spinners. Also, consider browsing from a mobile device where network connection could be unstable or slow, it might be very difficult to create a responsive user experience.

There are the following five strategies available to help reduce the amount and size of data requests:

Right Notes

Coding Conventions

Whitespace

  • Always spaces, never tabs
  • 2 spaces indents
@ilyavf
ilyavf / Gruntfile.js
Last active November 28, 2024 05:41
Steal tools build intermittent issue. Happens
...
grunt.initConfig({
'steal-build': {
main: {
options: {
system: {
config: __dirname + '/package.json!npm',
main: 'index'
},
buildOptions: {
@ilyavf
ilyavf / README.md
Last active September 15, 2016 05:46
CanJS: scope lookup examples

The ./ is used to refer to current scope without parent lookup. The ../ is used to look up values in parent scope. A scope is defined:

  • either for a helper like: {{#each items}} here current scope {{./}} will refer to the current element of items {{/each}}
  • or for a component: <bit-tabs> here {{./}} will refer to bit-tabs' viewModel </bit-tabs>.

The lookup is done automatically, but if one and the same property is defined (or even undefined but still intended to be) for both the current scope and the parent scope, then you may want to specify which one you want to refer to by using {{../}} to climb up to parent or by {{./}} to stay on current scope.

@ilyavf
ilyavf / 0_readme.md
Last active November 2, 2016 17:42
can-fixture-socket for demo pages

The rough-demo.html just shows whats needed to make the demo working.

The rest is the better structurized example:

  • demo.html - demo with less boilerplate.
  • contribution-months.js - exports mockContributionMonthsService that expects mockServer and mocks Feathers service for contributionMonths;
  • contribution-months.json - json data for can-fixture.store to be used for mocking Feathers service.
@ilyavf
ilyavf / 0_readme.md
Last active November 2, 2016 23:02
can-fixture-socket for test pages

Socket.io, can-fixture-socket and mocked services need to be evaluated before importing app models.

Async tests have to wait till dynamic import completes.

@ilyavf
ilyavf / README.md
Last active November 4, 2016 19:54
The need to delay socket.io connections for testing

TL;DR

To test a module that uses socket.io we need to intercept a socket.io connection and mock a server responses. If a module tries to establish a socket.io connection immediately on a module evaluation then it won't reach the mocked socket.io.

To overcome the problem we either have to delay the evaluation of the modules we test, or delay establishing the socket.io connection.

The steal-socket package addresses the problem using the second option.

Overview

Goal

Show how to test RESTful front-end models that use socket.io as its transport.

Plan

  1. Warm up: build a small app with realtime communication using socket.io (maybe a chat).
  2. Refactor: rebuild model layer to be RESTful via sockets.
  3. Ask how should we test this, and talk about options.
  4. Show what can-socket-fixture is for, and try to test with it.
@ilyavf
ilyavf / 0_readme.md
Last active December 6, 2016 18:53
steal is trying to load package.json from a wrong location

Install project

$ git clone https://github.com/donejs/bitcentive && cd bitcentive
$ git checkout fail-loading
$ npm install
$ npm start

Note: the app is served from /public with its own /public/node_modules.