Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/levyks/tepkijs
https://github.com/levyks/tepkijs
Last synced: 8 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/levyks/tepkijs
- Owner: Levyks
- License: gpl-3.0
- Created: 2022-01-06T15:59:25.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2022-03-06T18:20:17.000Z (over 2 years ago)
- Last Synced: 2024-11-06T18:08:45.141Z (12 days ago)
- Language: TypeScript
- Size: 55.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Tepki.JS
## Work in Progress
Remote stores powered by Socket.IO with a Vue/Vuex like syntax in the backend.
[Client repo](https://github.com/Levyks/tepkijs-client)
Server:
```ts
import { createStore } from 'tepkijs';
import { Server } from 'socket.io';const io = new Server(5000, {
cors: {
origin: '*',
}
});const store = createStore({
io, name: 'room-01',
data: {
messages: [],
_somethingPrivate: {}
},
methods: {
addMessage(message) {
this.messages.push(message);
}
}
});
```Client (Svelte):
`stores.ts`:
```ts
import { createStore } from 'tepkijs-client';
import type { TepkiStore } from 'tepkijs-client';type State = {
messages: string[]
}export const store: TepkiStore = createStore('room-01', 'http://localhost:5000');
```
```svelteimport { store } from './stores';
let message = '';
function sendMessage() {
store.call('addMessage', message);
message = '';
}{#if $store.isConnected}
- {message}
{#each $store.messages as message}
{/each}
Send
{/if}
```