Skip to content

Instantly share code, notes, and snippets.

View Vintharas's full-sized avatar
👶
Parenting

Jaime Vintharas

👶
Parenting
View GitHub Profile
@Vintharas
Vintharas / sublime_text_windows.json
Created November 15, 2014 16:27
Sublime text preferences windows
{
"bold_folder_labels": true,
"caret_style": "phase",
"color_scheme": "Packages/Dayle Rees Color Schemes/sublime/hyrule.tmTheme",
"draw_white_space": "all",
"fade_fold_buttons": false,
"font_face": "Inconsolata",
"font_size": 14.0,
"highlight_line": true,
"highlight_modified_tabs": true,
@Vintharas
Vintharas / knockout-subscribables.js
Created June 2, 2013 19:33
Subscribers to knockout observables are notified as soon as the observable changes
// src/subscribables/subscribable.js
"notifySubscribers": function (valueToNotify, event) {
event = event || defaultEvent;
if (this._subscriptions[event]) {
ko.dependencyDetection.ignore(function() {
ko.utils.arrayForEach(this._subscriptions[event].slice(0), function (subscription) {
// In case a subscription was disposed during the arrayForEach cycle, check
// for isDisposed on each subscription before invoking its callback
@Vintharas
Vintharas / knockout-observables-with-object-values.js
Last active December 18, 2015 00:09
By default knockout notifies subscribers of a change when an object value is written, even if it is identical to the old one
// spec/observableBehaviors.js
it('Should notify subscribers of a change when an object value is written, even if it is identical to the old value', function() {
// Because we can't tell whether something further down the object graph has changed, we regard
// all objects as new values. To override this, set an "equalityComparer" callback
var constantObject = {};
var instance = new ko.observable(constantObject);
var notifiedValues = [];
instance.subscribe(notifiedValues.push, notifiedValues);
instance(constantObject);
expect(notifiedValues).toEqual([constantObject]);