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
// In the Effect's constructor, inject store. | |
constructor(private store: Store<AppState>) | |
... | |
@Effect() | |
fetchUserProfile$: Observable<Action> = this.actions$.pipe( | |
ofType<FetchUserProfile>(UserActionTypes.FETCH_USER_PROFILE), | |
withLatestFrom(this.store), | |
mergeMap(([action, appState]) => { | |
return this.http | |
.get( |
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
@Effect() | |
search$: Observable<Action> = this.actions$.pipe( | |
ofType(SearchActions.SEARCH), | |
switchMap(action => { | |
const query = action.payload; | |
return [new FetchPanel1Data(query), new FetchPanel2Data(query)]; | |
}) | |
); |
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
@Effect() | |
getTabData$: Observable<Action> = this.actions$.pipe( | |
ofType<FetchTabData>(TabActions.FETCH_TAB_DATA), | |
switchMap(action => { | |
const tabType = action.payload; | |
return this.http | |
.get(`${environment.apiUrl}/api/tab/${tabType}`) | |
.pipe( | |
map((response: any) => { | |
return new FetchTabDataSuccess(response.data); |
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
@Effect({dispatch: false}) | |
entityCreationSuccess$: Observable<Action> = this.actions$.pipe( | |
ofType(UserActions.CREATE_USER_SUCCESS, PostActions.CREATE_POST_SUCCESS), | |
tap(action => { | |
this.router.navigate(['../'], {relativeTo: this.route}) | |
}) | |
); |
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
<!-- <div class="date-range"> | |
<div class="date-range__presets"> | |
<button #presetsTrigger | |
mat-raised-button | |
[matMenuTriggerFor]="presetMenu" | |
(click)="$event.stopPropagation()">{{selectedPreset.name}} | |
<mat-icon>arrow_drop_down</mat-icon> | |
</button> | |
<mat-menu #presetMenu="matMenu" | |
[overlapTrigger]="false"> |
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 quickSort(array, left = 0, right = array.length - 1) { | |
console.log("CALLED"); | |
let partitionIndex; | |
let pivotIndex; | |
if(left < right) { | |
pivotIndex = right; | |
partitionIndex = partition(array, left, right, pivotIndex); | |
quickSort(array, left, partitionIndex - 1); | |
quickSort(array, partitionIndex + 1, right); | |
} |
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 flatten(array) { | |
return array.reduce( (acc, e) => { | |
if(Array.isArray(e)) { | |
// if the element is an array, fall flatten on it again and then take the returned value and concat it. | |
return acc.concat(flatten(e)); | |
} else { | |
// otherwise just concat the value. | |
return acc.concat(e); | |
} | |
}, [] ) // initial value for the accumulator is [] |
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
// Updated on 16th May, 2024 based on @chamie's suggestion. | |
const response = await fetch("http://path/to/audio.wav"); | |
const data = await response.arrayBuffer(); | |
const blob = new Blob([data], { type: "audio/wav" }); | |
const blobUrl = URL.createObjectURL(blob); | |
const audio = new Audio(); | |
audio.src = blobUrl; | |
audio.controls = true; | |
document.body.appendChild(audio); |
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 VueApollo from 'vue-apollo'; | |
import { | |
createApolloClient, | |
restartWebsockets | |
} from 'vue-cli-plugin-apollo/graphql-client'; | |
import ApolloClient from 'apollo-client'; | |
import { InMemoryCache } from 'apollo-cache-inmemory'; | |
import { SubscriptionClient } from 'subscriptions-transport-ws'; | |
import router from '@/router'; |
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
{ | |
"name": "Issues", | |
"children": [ | |
{ | |
"name": "Word 1", | |
"children": [ | |
{ | |
"value": 8052, | |
"name": "Word 1" | |
}, |