Skip to content

Instantly share code, notes, and snippets.

View Gaurav0's full-sized avatar
💭
I'm looking for new opportunities!

Gaurav Munjal Gaurav0

💭
I'm looking for new opportunities!
View GitHub Profile
import Controller from '@ember/controller';
import { tracked } from '@glimmer/tracking';
import { action } from '@ember/object';
class Item {
@tracked count;
constructor(content, count) {
this.content = content;
this.count = count;
}
import Controller from '@ember/controller';
export default class ApplicationController extends Controller {
appName = 'Ember Twiddle';
}
import Controller from '@ember/controller';
import { action } from '@ember/object';
export default class AnimationSimpleDivDrag extends Controller {
// initialise grid properties
dragCardPositionDelta = { dx: 0, dy: 0 };
isDraggingCard = false;
constructor(...args) {
super(...args);
@Gaurav0
Gaurav0 / classes.my-class\.js
Last active May 5, 2021 14:41
Inject owner into class
import { setOwner } from '@ember/application';
import { inject as service } from '@ember/service';
export default class MyClass {
@service myService;
constructor(owner) {
setOwner(this, owner);
this.appName = this.myService.appName;
}
@Gaurav0
Gaurav0 / components.ui-checkbox\.js
Created September 15, 2020 02:03
Why Ember Demo
import Component from '@glimmer/component';
import { guidFor } from '@ember/object/internals';
export default class extends Component {
elementId = null;
constructor() {
super(...arguments);
this.elementId = guidFor(this);
<ol>
<li>Open browser dev tools</li>
<li>click "Make True"</li>
<li>click "Make False"</li>
<li>Notice an error in the console</li>
</ol>
<button {{on 'click' this.makeTrue}}>
Make True
</button>
@Gaurav0
Gaurav0 / controllers.application\.js
Last active June 11, 2020 22:23 — forked from gabrielgrant/controllers.application\.js
persistent mapbox markers MCVE
import Controller from '@ember/controller';
import { action } from '@ember/object';
import { tracked } from '@glimmer/tracking';
import 'mapbox-gl';
const center = {lng: 79.3832, lat: 43.6532};
function generateModel() {
return Array(3).map(pt => ({
lng: center.lng + Math.random() / 10,
import Controller from '@ember/controller';
import { action } from '@ember/object';
import { tracked } from '@glimmer/tracking';
export default class ApplicationController extends Controller {
appName = 'Ember Twiddle';
@tracked
fruits = [
'apples',
@Gaurav0
Gaurav0 / controllers.application\.js
Created May 22, 2020 21:23
Invoke Action in Octane
import Controller from '@ember/controller';
import { action } from '@ember/object';
export default class ApplicationController extends Controller {
appName = 'Ember Twiddle';
@action
onRouteChange() {
console.log('changing route');
}
@Gaurav0
Gaurav0 / controllers.application\.js
Last active May 8, 2020 17:54
escape-css-helper
import Controller from '@ember/controller';
export default class ApplicationController extends Controller {
appName = 'Ember Twiddle';
theColor = 'red';
}