Skip to content

Instantly share code, notes, and snippets.

import React, { useState } from 'react';
import './RoombaGrid.css';
// 90 right | 180 down | 270 left | 0 up
enum Direction {
'up' = 0,
'right' = 90,
'down' = 180,
'left' = 270,
@alexmgrant
alexmgrant / Board.tsx
Last active December 2, 2020 16:53
Board Component
import React, { useState, useEffect } from 'react';
import { getWinner } from './game-rules';
import './Grid.css';
enum Player {
playerOne = 'X',
playerTwo = 'O',
}
// there are examples I have where I would need to use load() as a callback after mutating the service collection
// I know there are 'hacks' to repaint the dom with ng1
// point is we have to worry about or data being up to date in the view
load() {
this.service.load() // here you may recieve a promise or observable depending on which angular version you're in
-> this.collection = response;
}
save(item) {
@alexmgrant
alexmgrant / global-ctrl.ts
Last active March 21, 2016 18:09
An added animation for ionic 1.0 that slides the view from the bottom to the top.
/* I have a gloabal ctrl which sits within my tabs.html. This way I have access to the global view model (controller) whereveer I want. */
TabsCtrl.$inject = ['$ionicViewSwitcher', '$ionicHistory'];
export default function TabsCtrl($ionicViewSwitcher, $ionicHistory) {
/* use our custom animation on click when this method is called */
function actionView(isExit) {
if ($ionicHistory.backView() !== null) {
var backView = $ionicHistory.backView();
/* sometimes we want native transitions even though we are returning from a slide in up animation.
#Let's build a native an app with web technology: The Challenge
###Why building Native is difficult
* compiling e...v...e...r...y... t...i...m...e! Thank you node.
* creating views is difficult. Manually compute size and layout of our views.
* we're web developers who enjoy the increased productivity that comes with our
modern development environment.
###Why Native is better
* platform-specific UI components, like maps, date pickers, switches, navigation