This file contains hidden or 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
/* | |
This function reads a specific binary file format used by VirtualScape. | |
VirtualScape map editor: https://github.com/didiers/virtualscape | |
*/ | |
export default function readVirtualscapeMapFile(file) { | |
return new Promise((resolve, reject) => { | |
const reader = new FileReader() | |
reader.onloadend = () => { | |
const arrayBuffer = reader.result | |
const virtualscapeMap = processVirtualscapeArrayBuffer(arrayBuffer) |
This file contains hidden or 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 React from 'react' | |
type WorkerArgs = { | |
some: string | |
} | |
/* myCoolWorker.js | |
// because we specify {type: 'module} in worker options, we can import from our project! | |
import { coolFn } from './someDir/coolFn' | |
self.onmessage = (event) => { |
This file contains hidden or 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
# Pub/Sub in React Context | |
While React Context is a great way to share data between components, it doesn't inherently implement the Pub/Sub pattern. However, you can combine the two to create a Pub/Sub system within your React application. | |
Here's a simple implementation: | |
```js | |
import React, { createContext, useContext, useState, useEffect } from 'react'; | |
const EventContext = createContext(); |
This file contains hidden or 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 React from "react"; | |
import { Animated, Easing } from "react-native"; | |
import Svg, { Defs, RadialGradient, Stop, Ellipse } from "react-native-svg"; | |
const HUE_SPEED = 1; | |
const ANIMATION_DURATION = 4000; | |
// This wrapper component holds and animates the values for hue and position | |
export const AnimatedRadialGradient = () => { | |
const hueValue = React.useRef(new Animated.Value(0)).current; |