Skip to content

Instantly share code, notes, and snippets.

@elgordino
elgordino / controllers.application\.js
Created August 7, 2020 10:28
Tracked Property In Array
import Controller from '@ember/controller';
import { tracked } from '@glimmer/tracking';
import { action } from '@ember/object';
export class Room {
@tracked
checked = true;
}
@elgordino
elgordino / controllers.application\.js
Last active August 7, 2020 10:34
Tracked Property In Array
import Controller from '@ember/controller';
import { tracked } from '@glimmer/tracking';
import { action } from '@ember/object';
export class Room {
@tracked
checked = true;
}
import Controller from '@ember/controller';
import { computed, set } from '@ember/object';
export class Room {
_localAttributes = {};
_remoteAttributes = {};
save() {
import Ember from 'ember';
import { defineProperty, computed } from '@ember/object';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
init() {
const attrs = { firstName: 'Foo', lastName: 'Bar' };
const model = this.store.createRecord('my-model', attrs);
@elgordino
elgordino / event.json
Last active January 12, 2018 15:17
text-event
{"features":[{"name":"Schedule","type":"feature-schedule","id":"e6c6e9e2-f731-4321-97b7-fb23a19916a1-feature-schedule","icon":"13","sessions":[{"id":"12f7204b-c27b-469e-bf05-90572dcc263e","type":"schedule-session","startTime":"2017-12-29T10:45:00Z","endTime":"2017-12-29T11:45:00Z","title":"Second","description":"","location":"Main Room","tracks":[]},{"id":"764e51ec-9384-422f-923c-4d8805d6d4c4","type":"schedule-session","startTime":"2017-12-29T11:45:00Z","endTime":"2017-12-29T12:45:00Z","title":"First","description":"","location":"Main Room","tracks":[]}],"settings":{"type":"schedule-settings","timeFormat":"24","timeZone":"GMT","multiTrack":false}}]}
@elgordino
elgordino / server-timestamp-on-save.js
Last active July 31, 2017 07:46
This gist is for emberfire users. It's a Mixin that adds a property to DS.Model attributes that causes their value to be set to the special 'ServerValue.TIMESTAMP' on save.
import Ember from 'ember';
import firebase from 'firebase';
const { Mixin, get, set } = Ember;
/**
* A small Mixin for DS.Model for emberfire users that will set attributes that have
* 'setToServerTimeStampOnSave' to the firebase 'ServerValue.TIMESTAMP' on save.
* eg:
* clientUpdatedTime: attr('number', { setToServerTimestampOnSave: true }),
*/
@elgordino
elgordino / README.md
Last active July 8, 2018 22:30
An idea for adding path prefixes to models

This gist gives an outline of how emberfire could be modified to allow models to express their own path prefix.

When emberfire assembles a ref it will query the class of the record to see if it has a pathPrefix method, if it does the return of that method is prefixed to the ref that will be used.

The pathPrefix method could be expressed in a mixin then applied to the relevent classes.

@elgordino
elgordino / README.md
Last active June 4, 2017 12:43
An ember service to manage emberfire relationships and record values atomically.

Intro

This ember service provides a way to make attomic changes to relationships and record values in Firebase. This is useful when you have relationships that are not simple parent/child relationships or need to updated fields across multiple records in an atomic transaction.

This code has been copied directly from my project and is intended to be used as an example rather than being cut/pasted directly into your project! :)

Important

Please note this code is untested and usage is at your own risk!