@casperiv/use-socket.io
Advanced tools
Comparing version 6.0.0 to 6.0.1
import * as React from 'react'; | ||
import { io } from 'socket.io-client'; | ||
import { createWithEqualityFn } from 'zustand/traditional'; | ||
import { shallow } from 'zustand/shallow'; | ||
import { create } from 'zustand'; | ||
// src/core/provider.tsx | ||
var useSocketStore = create((set, get) => ({ | ||
socket: null, | ||
setSocket: (socket) => set({ socket }), | ||
options: {}, | ||
setOptions: (options) => set({ options: { ...get().options, ...options } }) | ||
})); | ||
var useSocketStore = createWithEqualityFn( | ||
(set, get) => ({ | ||
socket: null, | ||
setSocket: (socket) => set({ socket }), | ||
options: {}, | ||
setOptions: (options) => set({ options: { ...get().options, ...options } }) | ||
}), | ||
shallow | ||
); | ||
// src/hooks/useConnect.ts | ||
var useConnect = () => { | ||
const store = useSocketStore( | ||
(state) => ({ | ||
socket: state.socket, | ||
setSocket: state.setSocket | ||
}), | ||
shallow | ||
); | ||
const store = useSocketStore((state) => ({ | ||
socket: state.socket, | ||
setSocket: state.setSocket | ||
})); | ||
const connect = (url, options) => { | ||
@@ -24,0 +24,0 @@ if (store.socket?.connected) { |
{ | ||
"name": "@casperiv/use-socket.io", | ||
"version": "6.0.0", | ||
"version": "6.0.1", | ||
"description": "Use Socket.io-client with hooks", | ||
"license": "MIT", | ||
"homepage": "https://github.com/Dev-CasperTheGhost/use-socket.io#readme", | ||
"homepage": "https://github.com/casperiv0/use-socket.io#readme", | ||
"type": "module", | ||
@@ -18,3 +18,3 @@ "main": "./dist/index.js", | ||
"author": { | ||
"name": "Dev-CasperTheGhost", | ||
"name": "casperiv0", | ||
"url": "https://www.casperiv.dev" | ||
@@ -45,7 +45,7 @@ }, | ||
"@casperiv/eslint-config-react": "^8.0.0", | ||
"@types/react": "^18.2.20", | ||
"eslint": "^8.47.0", | ||
"prettier": "^3.0.2", | ||
"@types/react": "^18.2.21", | ||
"eslint": "^8.49.0", | ||
"prettier": "^3.0.3", | ||
"socket.io": ">=4.7", | ||
"typescript": "^5.1.6" | ||
"typescript": "^5.2.2" | ||
}, | ||
@@ -59,7 +59,7 @@ "peerDependencies": { | ||
"type": "git", | ||
"url": "https://github.com/Dev-CasperTheGhost/use-socket.io" | ||
"url": "https://github.com/casperiv0/use-socket.io" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/Dev-CasperTheGhost/use-socket.io/issues" | ||
"url": "https://github.com/casperiv0/use-socket.io/issues" | ||
} | ||
} |
@@ -42,2 +42,2 @@ # use-socket.io | ||
[You can view documentation here](https://github.com/Dev-CasperTheGhost/use-socket.io/blob/main/docs/README.md) | ||
[You can view documentation here](https://github.com/casperiv0/use-socket.io/blob/main/docs/README.md) |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6311