2.3.2 • Published 1 year ago

phoenix-provider v2.3.2

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Now is written by typescript

Can be check

API

import {
    Provider,
    Consumer,
    useSocket,
    useChannel,
    usePresence,
} from 'phoenix-provider';

React.rencer(
    <Provider url={'/socket'} options={{ params: {token: 'my-app-token' }}}>
        <App>
    </Provider>
)

const App = () => {
    const socket = useSocket();

    return (
        <div>
            <div>
                {socket.isConnected() ? 'connected' : 'disconnected'}
            </div>
            <div>
                <Channel />
            </div>
        </div>
    );
};

const Channel = () => {
    const [list, setList] = useState([]);
    const channel = useChannel('lobby', { user: 'Josh' });

    const presence = usePresence('lobby');

    useEffect(() => {
        presence.onSync(() => {
            setList(presence.list());
        });
    }, [presence]);

    return (
        <ul>
            {list?.map((l) => (
                <li>{l}</li>
            ))}
        </ul>
    );
}
2.3.2

1 year ago

2.3.0

2 years ago

2.3.1

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

2.2.0

2 years ago

2.0.2

2 years ago

2.1.0

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago