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
class QNode { | |
constructor(value) { | |
this.val = value; | |
this.next = null; | |
} | |
} | |
class MyQueue { | |
constructor() { | |
this.head = 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
import { useState, useCallback, useMemo, useEffect } from 'react'; | |
import { useMutation } from '@apollo/client'; | |
const INITIAL_DATA_VALUE = undefined; | |
const useResetableMutation = (query, options) => { | |
const [customData, setCustomData] = useState(INITIAL_DATA_VALUE); | |
const customOptions = useMemo(() => { | |
const onCompleted = (responseData) => { | |
setCustomData(responseData); | |
options && options.onCompleted && options.onCompleted(responseData); |
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
// thunk based action creator example, cannot be tested while calling mapDispatchToProps beside checking if dispatch was called | |
function saveScore (score) { | |
return (dispatch) => { | |
fetch('/scores', { method: 'POST', { score } }) | |
.then(() => { | |
dispatch({ type: SAVE_SCORE_SUCCEEDED }) | |
}) | |
} | |
} |