Skip to content

Instantly share code, notes, and snippets.

View weihungchin's full-sized avatar

nich weihungchin

  • United Kingdom
View GitHub Profile
@weihungchin
weihungchin / main.js
Created October 19, 2021 08:40
src/main.js
import { createApp } from 'vue'
import App from './App.vue'
import store from './store'
createApp(App).use(store).mount('#app')
@weihungchin
weihungchin / index.js
Created October 19, 2021 08:38
src/store/index.js
import { createStore } from 'vuex'
export default createStore({
state: {
},
mutations: {
},
actions: {
},
modules: {
import { tap, retryWhen } from 'rxjs/operators';
import { webSocket } from 'rxjs/webSocket';
import { timer } from 'rxjs';
const wsSubjectConfig = {
url: 'wss://www.gasnow.org/ws/gasprice',
// added this to the config object
closeObserver: {
// this is triggered when connection is closed
next(event) {
import { tap. retryWhen } from 'rxjs/operators';
import { webSocket } from 'rxjs/webSocket';
import { timer } from 'rxjs';
const wsSubjec2$ = webSocket({
url: 'wss://www.gasnow.org/ws/gasprice',
});
wsSubject$
.pipe(
import { tap } from 'rxjs/operators';
import { webSocket } from 'rxjs/webSocket';
const wsSubjec2$ = webSocket({
url: 'wss://www.gasnow.org/ws/gasprice',
});
const subA = wsSubject$
.pipe(
tap(data => console.log(data))
import { tap } from 'rxjs/operators';
import { webSocket } from 'rxjs/webSocket';
const wsSubjec2$ = webSocket({
url: 'wss://www.gasnow.org/ws/gasprice',
});
wsSubject$
.pipe(
tap((data) => console.log(data)),
import { webSocket } from 'rxjs/webSocket';
const wsSubject$ = webSocket('wss://www.gasnow.org/ws/gasprice');
// or
const wsSubjec2$ = webSocket({
url: 'wss://www.gasnow.org/ws/gasprice'
});
data class Song(val genre: String, val artist: String){
var title: String;
}
val songA: Song = Song("Pop", "Jamie")
val songB: Song = Song("Pop", "Jamie")
songA.title = "Take the train"
songB.title = "All blues"
songA.equals(songB) // true
class Song {
private String genre;
private String artist;
public Song(String genre, String artist) {
this.genre = genre;
this.artist = artist;
}
// Getter setter
@weihungchin
weihungchin / rxjs-zip.js
Last active January 16, 2021 11:23
Fetch wih Rxjs
import { tap } from "rxjs/operators";
import { zip } from "rxjs";
function getUser(id) {
return fetch(`https://jsonplaceholder.typicode.com/users/${id}`).then(res =>
res.json()
);
}
function getPost(userId) {