Skip to content

Instantly share code, notes, and snippets.

View saravanan10393's full-sized avatar
🎯
Focusing

Saravanan Ramupillai saravanan10393

🎯
Focusing
View GitHub Profile
# Name of the workflow
name: Deploy to firebase
# Trigger for workflow:-
# In this case, trigger this workflow when ever push happens on the master branch only when files
# present in web directory got changed
on:
push:
branches:
- master
paths:
function Admin() {
function prepareForCouncil() {
let servantA = ServantA();
let servantB = ServantB();
let servantC = ServantC();
//Now Admin has power to manage all the servants work with help of Promise.all
let overAllStatusPromise = Promise.all([
servantA.cleaningHall(),
servantB.arrangeTables(),
function ServantA() {
//for simplicity hidden the implementation
function cleaningHall() {
return new Promise(cleaningHallPromiseHandler);
}
return {
cleaningHall: cleaningHall
};
}
function Servant() {
function cleanRoomPromiseHandler(resolve, reject) {
//some complex logic goes here and
let cleanedRoom = true;
if(cleanedRoom) {
resolve("I cleaned the room my King");
}else {
reject("Sorry my King, I failed to clean room since i slept down ;(");
}
}
function Servant() {
function prepareHorsePromiseHandler(resolve, reject) {
//some complex logic goes here and
let horsesAreReady = true;
if(horsesAreReady) {
//fulfilling promise
resolve("Horses are ready my King :)");
}else {
//promise failed
reject("Sorry my King, I failed to prepared the horses since horse kicked me so hard ;(");
/* ============= util methods ========= */
let cache = null;
function getCache(cacheName = "apiCache") {
if (!cache) {
window.caches.open(cacheName).then(cach => {
cache = cach;
});
}
return cache;
}
@saravanan10393
saravanan10393 / hooks_form_validation.js
Created February 14, 2019 17:40
Generic util components for doing form validation in react with hooks.
import React, {
useEffect,
useImperativeHandle,
forwardRef,
useRef
} from "react";
export const Validation = forwardRef(function Validation({ children }, ref) {
const validatorRefs = useRef({});
@saravanan10393
saravanan10393 / RemoveHiddenDOMFromView.js
Last active September 24, 2018 06:44
React component to remove the children when it is hidden in view port
import React from "react";
import PropTypes from "prop-types";
export class FreeUpDOMWhenHidden extends React.Component {
static propTypes = {
className: PropTypes.string, // aditionaly className that will used to style
wrapper: PropTypes.node // React children
};
static defaultProps = {
@saravanan10393
saravanan10393 / InfinitescrollNotifier.js
Created September 24, 2018 06:25
Infinite scroll notifier based on IntersectionObserver API
import React from "react";
import PropTypes from "prop-types";
export class RefreshAtEnd extends React.Component {
static propTypes = {
root: PropTypes.string.isRequired, // list container
onVisible: PropTypes.func // callback to call when loading is visible
};
static defaultProps = {
<!DOCTYPE html>
<html>
<head>
<style>
body{
text-align: center;
}
.counterSetter{
box-shadow: 0px 2px 25px 0 rgba(17, 17, 24, 0.12);