Skip to content

Instantly share code, notes, and snippets.

View Loschcode's full-sized avatar
🌀
Probably coding

Laurent Schaffner Loschcode

🌀
Probably coding
View GitHub Profile
@Loschcode
Loschcode / a-wonderful-world.js
Last active March 18, 2019 20:23
If anyone wonders why the JS world is a fucking mess
// those 2 abstract of the same library are supposed to do the exact same thing, but are written totally differently
// because no one cared about restricting the way you should use their public API.
// because there's no real public API, because JS.
const hasSubscriptionOperation = ({ query: { definitions } }) => {
return definitions.some(
({ kind, operation }) =>
kind === 'OperationDefinition' && operation === 'subscription'
)
}
import gql from 'graphql-tag'
const mutation = gql`
mutation CreateGuest {
createGuest {
token
}
}
`
import _ from 'lodash'
import createGuest from '@/graphql/mutations/createGuest'
import EventsService from '@/services/EventsService'
export default vm => {
const events = new EventsService(vm)
const perform = async () => {
if (getToken() == null) await connectGuest()
return getToken()
<script>
import getTokenOperation from '@/operations/getTokenOperation'
import EventsService from '@/services/EventsService'
import PageHelper from '@/helpers/PageHelper'
import { currentIdentity } from '@/graphql/queries/currentIdentity'
export default {
data () {
return {
import EventBus from '@/misc/EventBus'
import PageHelper from '@/helpers/PageHelper'
class EventsService {
constructor(vm) {
this.vm = vm
}
/**
* All the event bus related things
import EventBus from '@/misc/EventBus'
import PageHelper from '@/helpers/PageHelper'
const EventsFactory = vm => ({
setup() {
setupRebootEvent(vm)
setupCrashEvent(vm)
setupErrorEvent(vm)
},
import _ from 'lodash'
import createGuest from '@/graphql/mutations/createGuest'
import EventsService from './EventsService'
export default vm => ({
identityToken: vm.identityToken,
events() {
return new EventsService(vm)
},
import _ from 'lodash'
import createGuest from '@/graphql/mutations/createGuest'
import EventsService from './EventsService'
class ConnectService {
constructor(vm, identityToken) {
this.vm = vm
this.identityToken = identityToken
this.events = new EventsService(vm)
import _ from 'lodash'
import createGuest from '@/graphql/mutations/createGuest'
import EventsService from './EventsService'
class ConnectService {
constructor(vm, identityToken) {
this.vm = vm
this.identityToken = identityToken
this.events = new EventsService(vm)
import _ from 'lodash'
import createGuest from '@/graphql/mutations/createGuest'
import EventsService from './EventsService'
class ConnectService {
constructor(vm, identityToken) {
this.vm = vm
this.identityToken = identityToken
this.events = new EventsService(vm)