This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Comportamental - Como os objetos dependentes se mantem atualizados | |
interface Observer { | |
update: () => void | |
} | |
interface Subject { | |
attach: (observer: Observer) => void, | |
detach: (observer: Observer) => void, | |
notify: () => void, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// @ts-nocheck | |
import Vue from 'vue' | |
const events = ['click', 'touchstart', 'scroll'] | |
function onClickOutside ({ event, el, handler }) { | |
const isClickOutside = event.target !== el && !el.contains(event.target) | |
if (!isClickOutside) { return null } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Constructors | |
// Be careful when using | |
// Constructor pattern | |
function C() { | |
this.instanceMember = 'Whoops!!' | |
} | |
const c = C() // Forgot 'new' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Observer { | |
update: () => void; | |
} | |
interface Subject { | |
subscribe: (observer: Observer) => void, | |
unsubscribe: (observer: Observer) => void, | |
notify: () => void, | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
import Driver from 'driver.js'; | |
import 'driver.js/dist/driver.min.css'; | |
import { steps } from './steps'; | |
export default { | |
computed: { | |
driver() { | |
return new Driver({ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import snackBarComponent from '@/components/global/snackBar'; | |
const snackBarPlugin = { | |
install: (Vue, options = {}) => { | |
let isHolderCreated = false; | |
const idName = 'snackbar', | |
ToastConstructor = Vue.extend(snackBarComponent); | |
const createHolder = () => { | |
let holder = document.createElement('div') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Returns a "state" reactive object, that contains the following properties | |
* result: Result from promise if there's any | |
* error: Error from promise if there's any | |
* isLoading: Boolean that signals if our promise is Loading or not | |
* retry_attempts: Tracks how many retries we already did | |
* | |
* And the following method | |
* retry: Will automatically retry our promise and reasign all values | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Vue from 'vue'; | |
import Vuetify from 'vuetify'; | |
import { createLocalVue, shallowMount, mount } from '@vue/test-utils'; | |
// I'do prefer to create a mocks file for those global fellas | |
// import mocks from './mocks'; | |
Vue.use(Vuetify); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const sortList = ( list, field_default, field = field_default, order = 'a_z' ) => { | |
list.sort(comparator(field, order)); | |
}; | |
const comparator = (field, order) => { | |
return (a, b) => { | |
const comparation_table = { | |
a_z: a[field] == b[field] ? 0 : a[field] < b[field] ? -1 : 1, | |
z_a: a[field] == b[field] ? 0 : a[field] > b[field] ? -1 : 1, | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function randomDate(start, end) { | |
return new Date(start.getTime() + Math.random() * (end.getTime() - start.getTime())); | |
} | |
console.log(randomDate(new Date(2012, 0, 1), new Date())); |