How to use the phoenix.Presence.list function in phoenix

To help you get started, we’ve selected a few phoenix examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DefinitelyTyped / DefinitelyTyped / phoenix / phoenix-tests.ts View on Github external
console.log("user has left from all devices", leftPres)
      } else {
        console.log("user left from a device", leftPres)
      }
    };

    state = Presence.syncState(state, stateFromServer, onJoin, onLeave);

    const listBy = (id: string, {metas: [first, ...rest]} : {metas: any[]}) => {
      first.count = rest.length + 1;
      first.id = id;

      return first;
    };

    const onlineUsers = Presence.list(state, listBy);
}
github danieldocki / slack-clone-vuejs-elixir-phoenix / web / src / store / session / actions.js View on Github external
export const syncPresentUsers = ({ commit }, presences) => {
  const presentUsers = [];
  Presence.list(presences, (id, { metas: [first] }) => first.user)
          .map(user => presentUsers.push(user))
  commit(TYPES.ROOM_PRESENCE_UPDATE, presentUsers)
}
github stride-nyc / remote_retro / web / static / js / components / remote_retro.jsx View on Github external
retroChannel.on("presence_state", presences => {
      const users = Presence.list(presences, (_userToken, presence) => (presence.user))
      actions.setUsers(users)
    })
github rsilvestre / phoenix-react-redux-starter-kit / web / static / js / modules / session.js View on Github external
interfaceChannel.on('presence_diff', diff => {
            presences = Presence.syncDiff(presences, diff)
            dispatch(updatePresences(Presence.list(presences, listBy)))
          })
github bnhansn / sling / web / src / actions / room.js View on Github external
const syncPresentUsers = (dispatch, presences) => {
  const presentUsers = [];
  Presence.list(presences, (id, { metas: [first] }) => first.user)
          .map((user) => presentUsers.push(user));
  dispatch({ type: 'ROOM_PRESENCE_UPDATE', presentUsers });
};
github rsilvestre / phoenix-react-redux-starter-kit / web / static / js / modules / session.js View on Github external
interfaceChannel.on('presence_state', state => {
            presences = Presence.syncState(presences, state)
            dispatch(updatePresences(Presence.list(presences, listBy)))
          })