Skip to content

Instantly share code, notes, and snippets.

View BrianJVarley's full-sized avatar

Brian Varley BrianJVarley

View GitHub Profile
@BrianJVarley
BrianJVarley / crossControlValidation.js
Created July 4, 2020 19:45
Cross Control Validation Angular Forms
let input1$ = this.form.controls.input1.valueChanges;
let input2$ = this.form.controls.input2.valueChanges;
let input3$ = this.form.controls.input3.valueChanges;
combineLatest(input1$, input2$, input3$)
.do(([input1, input2, input3]) => {
this.form.controls.input1.clearAsyncValidators();
})
.debounceTime(500)
.subscribe(([input1, input2, input3]) => {
let timeout = 1000;
/**
* Create a custom observable that creates a XHR request and returns complete when the promise is fulfilled
*/
let observable = Rx.Observable.create((o) => {
dataService.fetch('test.json')
.then((data) => {
o.onNext(data);
o.onCompleted();
@BrianJVarley
BrianJVarley / ENVIRONMENT.MD
Created February 7, 2019 22:54
Local Machine environment - react-native development

ENVIRONMENT DETAILS

Windows 7 64bit

$ react-native -v react-native-cli: 2.0.1 react-native: 0.42.0

@BrianJVarley
BrianJVarley / DeckSwiperComponent.js
Last active October 23, 2018 20:42
Example of NativeBase DeckSwiperComponent cut off of text in CardItem
import React, {Component, PropTypes} from 'react';
import {Image, Animated, StyleSheet,ScrollView} from 'react-native';
import {
DeckSwiper,
Card,
CardItem,
Thumbnail,
Text,
Left,
Right,
import React, {Component, PropTypes} from 'react';
import {TouchableWithoutFeedback,View,Dimensions,
StyleSheet, Image, Text, TouchableOpacity} from 'react-native';
import Overlay from 'react-native-overlay';
import FloatLabelTextInput from 'react-native-floating-label-text-input';
import {Button, Icon, Item, Input} from 'native-base';
import AwesomeAlert from 'react-native-awesome-alerts';
import DismissKeyboard from 'react-native-dismiss-keyboard';
import SettingMenuContainer from '../settings/SettingMenuContainer';
import AppStrings from '../../localization/appStrings';
import React, {Component, PropTypes} from 'react';
import {TouchableWithoutFeedback,View,Dimensions,
StyleSheet, Image, Text, TouchableOpacity} from 'react-native';
import Overlay from 'react-native-overlay';
import FloatLabelTextInput from 'react-native-floating-label-text-input';
import {Button, Icon, Item, Input} from 'native-base';
import AppStrings from '../../localization/appStrings';
import {cleanNumericString} from '../../utils/stringUtils';
import {SOP_BLUE} from './../../styles/commonStyles';
@BrianJVarley
BrianJVarley / DeckSwiperComponent.js
Last active September 13, 2018 21:10
Image swiper component based off native base deck swiper
import React,{Component, PropTypes} from 'react';
import {Image} from 'react-native';
import {Container, View, DeckSwiper, Card, CardItem,
Thumbnail, Text, Left, Right, Body, Icon, Button} from 'native-base';
import {SOP_ORANGE, SOP_WHITE} from './../styles/commonStyles';
import AppStrings from './../localization/appStrings';
const defaultCards = [
{
title: 'Card One',
@BrianJVarley
BrianJVarley / AppStrings.js
Last active December 10, 2021 07:26
Mocking react-native-localization package in jest spec
// ES6 module syntax
import LocalizedStrings from 'react-native-localization';
let AppStrings = new LocalizedStrings({
'en-US': {
settingMenuOptionOne: 'Centimeters ({0})',
},
en: {
settingMenuOptionOne: 'Centimeters ({0})',
},
@BrianJVarley
BrianJVarley / offsetCalculateServiceMiddleware.js
Created July 9, 2018 21:12
service middleware example to set UNit of measure when action dispatched.
function offsetCalculateServiceMiddleware(offsetCalculateService) {
return ({ dispatch, getState }) => next => action => {
if (action.type == 'CALCULATE') {
myService.setUnitOfMeasurement(getState().getIn(['settings']).toJSON());
}
return next(action);
}
}
@BrianJVarley
BrianJVarley / SquareOffsetView.js
Created March 10, 2018 19:52
Example of AwesomeALert component css override
import React, {Component, PropTypes} from 'react';
import {TouchableWithoutFeedback,View,Dimensions,
StyleSheet, Image, Text, TouchableOpacity} from 'react-native';
import Overlay from 'react-native-overlay';
import FloatLabelTextInput from 'react-native-floating-label-text-input';
import {Button,Badge,Icon} from 'native-base';
import AwesomeAlert from 'react-native-awesome-alerts';
import dismissKeyboard from 'react-native-dismiss-keyboard';
const ScreenWidth = Dimensions.get('window').width;