Skip to content

Instantly share code, notes, and snippets.

View eldonwilliams's full-sized avatar
😁

Eldon Williams eldonwilliams

😁
View GitHub Profile
-- CONFIG
local RequestWaitTime: number = 5
local RequestURL: string = "https://eldon.zone/api/roblox/games/2316994223"
local MemoryStoreService = game:GetService("MemoryStoreService")
local Messaging = game:GetService("MessagingService")
local RunService = game:GetService("RunService")
local HttpService = game:GetService("HttpService")
local FavoritesProvider = MemoryStoreService:GetSortedMap("FAVORITES")
@eldonwilliams
eldonwilliams / useSocket.js
Created January 17, 2022 00:16
React.js hook wrapper around socket.io-client sockets. Also methods for making sure socket is safe to make calls on.
import { useEffect, useState } from "react";
import { io } from "socket.io-client";
/**
*
* @param {Object} options Options variable
* @param {string} [options.url=window.location] The location to attempt to connect a socket
* @param {Partial<import("socket.io-client").ManagerOptions & import("socket.io-client").SocketOptions>} [options.options={}] The options object to pass to io
* @returns {[import("socket.io-client").Socket, isSocketSafe, runSafely]}
*/
/*
CREATED BY: DEVVY/DEVTOPS
This is a react hook that allows you to create a state which will hold multiple values.
While this can be inefficient in some cases, it is useful when you don't need tons of states cluttering your code.
You can edit and use this as you'd like, but I'd appreciate if the creator tag was left in :)
P.S. : I tried to use minimal type checking, so that may give you some ~weird~ errors, or ones that don't make sense.
Feel free to edit this to add more specific checks.