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
export WEBOTS_HOME=/home/tom/develop/$WEBOTS_VER | |
export LD_LIBRARY_PATH="/home/tom/develop/$WEBOTS_VER/lib" | |
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64 | |
export WEBOTS_ALLOW_MODIFY_INSTALLATION=true | |
export WEBOTS_DISABLE_SAVE_PERSPECTIVE_ON_CLOSE=1 | |
alias web="cd $WEBOTS_HOME" | |
alias webots=/home/tom/develop/$WEBOTS_VER/webots | |
alias trans="web; git checkout -- $WEBOTS_HOME/resources/translations" | |
alias mks="make release -j 12 -C $WEBOTS_HOME/src/webots" |
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
const useMounted = () => { | |
const isMounted = useRef(false); | |
useEffect(() => { | |
isMounted.current = true; | |
return () => { | |
isMounted.current = 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
const useWebSocket = (url, protocols, onMessage, onError) => { | |
const ws = useRef(null); | |
useEffect(() => { | |
const socket = new WebSocket(url, protocols); | |
socket.onmessage = onMessage; | |
socket.onerror = onError; | |
ws.current = socket; | |
return () => { | |
ws.current.close(); | |
}; |
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
const ChatView = () = { | |
const wsRef = useWebSocket( | |
'wss://example.com/chat', | |
null, | |
(message) => alert(message), | |
() => alert('error!') | |
); | |
return ( |
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
useCode( | |
() => [ | |
cond(and(not(breathing), clockRunning(clock)), stopClock(clock)), | |
cond( | |
and(not(not(breathing)), not(clockRunning(clock))), | |
startClock(clock) | |
), | |
set(animation, [ | |
loop({ | |
duration: 5000, |
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
const mult = (a, b) => { | |
'worklet'; | |
return a * b; | |
} |
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
progress.value = withTiming(100, { duration: 1000 }); |
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
const animation = useSharedValue(0); | |
const animateCircle = (breathing) => { | |
if (!breathing) animation.value = 0; | |
else { | |
animation.value = withRepeat( | |
withTiming(1, { | |
duration: 5000, | |
reverse: true, | |
easing: Easing.inOut(Easing.ease), |
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 } from "react"; | |
const useLoading = (action) => { | |
const [loading, setLoading] = useState(false); | |
const doAction = (...args) => { | |
setLoading(true); | |
return action(...args).finally(() => setLoading(false)); | |
}; |
OlderNewer