Skip to content

Instantly share code, notes, and snippets.

View ispoljari's full-sized avatar
💻
Working from home

Ivan Špoljarić ispoljari

💻
Working from home
View GitHub Profile
@ispoljari
ispoljari / auth.spec.ts
Created September 29, 2021 08:18
Store with module instantiation
const storeOptions = {
modules: {
auth: AuthModule,
},
};
const createStore = (storeOptions: any = {}): Store<{ auth: IState }> => new Vuex.Store({ ...storeOptions });
@ispoljari
ispoljari / solution.ts
Created September 29, 2021 08:15
Multiple solution related files
// auth.spec.ts
import Vuex, { Store } from 'vuex';
import { createLocalVue } from '@vue/test-utils';
import AuthModule, { IState } from './auth';
jest.mock('@/services');
const localVue = createLocalVue();
@ispoljari
ispoljari / AuthModule.ts
Created September 29, 2021 08:10
AuthModule
@Module({
stateFactory: true,
namespaced: true,
})
export default class AuthModule extends VuexModule {
userData?: UserData | undefined = undefined;
prevRouteList: Routes[] = [];
error?: services.ICognitoError | undefined = undefined;
isLoading = false;
...
@ispoljari
ispoljari / README.md
Created September 9, 2021 11:38 — forked from letanure/README.md
VueJS Best Practices Guide

Deverus Vue.js Style Guide

Guide for developing Vue.js applications.

v. 0.0.1

Vue.js is an amazing framework, which can be as powerful as Angular or React, the two big heavy hitters in the world of front-end frameworks.

However, most of Vue's ease-of-use is due to the use of Observables - a pattern that triggers re-renders and other function calls with the reassignment of a variable.

@ispoljari
ispoljari / eq_reasoning.js
Created June 6, 2020 12:09
Use of equational reasoning
// step 1.
const areCompatibleMatch = (mike, jane) => (
'running' ==== 'running' || // ref. transparency
'pizza' ==== 'lasagne' ? // ref. transparency
generateMessage("Mike", "Jane") :
false;
);
// step 2.
@ispoljari
ispoljari / match_maker.js
Created June 6, 2020 12:07
bad take on a match making algorithm
const { Map } = require('immutable');
const mike = Map({
name: 'Mike',
age: 28,
hobby: 'running',
favouriteFood: 'pizza'
});
const jane = Map({
@ispoljari
ispoljari / planets.js
Created June 6, 2020 12:05
cut planets
["venus", "mars"];
@ispoljari
ispoljari / slice.js
Created June 6, 2020 12:05
slice planets
const slicedPlanets = planets.slice(2,4);
@ispoljari
ispoljari / inventory.js
Created June 6, 2020 12:04
inventory object
const inventory = Object.freeze({
cars: [], // example types
boats: [], // example types
trains: [] // example types
});
@ispoljari
ispoljari / pure_fns.js
Created June 6, 2020 12:03
Example of pure functions
const planets = ['earth', 'mercury', 'venus', 'mars', 'jupiter'];
const slicedPlanets = planets.slice(2,4);
const inventory = {
cars: [], // example types
boats: [], // example types
trains: [] // example types
};
const removeVehicleTypeFromInventory = (type, inventory) => {