This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule ChannelHandler do | |
def process_plugs(plugs, socket, payload, bindings \\ %{}) do | |
result = | |
Enum.reduce_while(plugs, {socket, payload, bindings}, | |
fn plug, {socket, payload, bindings} -> | |
case process_plug(plug, socket, payload, bindings) do | |
{:cont, socket, payload, bindings} -> {:cont, {:cont, socket, payload, bindings}} | |
{:halt, socket, status, reason} -> {:halt, {:halt, socket, status, reason}} | |
end | |
end) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@spec call(Phoenix.Socket.t, payload :: any, bindings :: any, opts :: any) :: | |
{:cont, Phoenix.Socket.t, payload :: any, bindings :: any} | |
| {:halt, status :: atom, reason :: any} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@spec call(socket :: Phoenix.Socket.t, opts :: any) :: Phoenix.Socket.t |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Felt.Channel.ElementHandler do | |
def handle_event(event, payload, socket) when event in ["create", "update", "delete"] do | |
with :ok <- ensure_map_editable(socket) do | |
do_handle_event(event, payload, socket) | |
else | |
{:error, reason} -> | |
{:reply, {:error, reason}, socket} | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Felt.Channel.ElementHandler do | |
def handle_event("create", payload, socket) do | |
with :ok <- ensure_map_editable(socket) do | |
# Create the element | |
end | |
end | |
def handle_event("update", payload, socket) do | |
with :ok <- ensure_map_editable(socket) do | |
# Update the element |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plug MyAppWeb.Plugs.EnsureAuthenticated |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def handle_call("element:" <> event, payload, socket) do | |
FeltWeb.Channels.ElementHandler.handle_event(event, payload, socket) | |
end | |
def handle_call("layer:" <> event, payload, socket) do | |
FeltWeb.Channels.LayerHandler.handle_event(event, payload, socket) | |
end | |
def handle_event("sync:" <> event, payload, socket) do | |
FeltWeb.Channels.SyncHandler.handle_event(event, payload, socket) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plug MyAppWeb.Plugs.CheckFeatureFlag, | |
:upload_anything when action in [:import_layer, :import_elements] | |
def import_layer(conn, params) do | |
# Will run if feature flag is enabled, fail otherwise | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public generateExpression(): MapLibreExpression { | |
return [ | |
"interpolate", | |
["exponential", this.base], | |
["zoom"], | |
...this.stops.map((stop) => [stop[0] - 1, stop[1]]).flat(), | |
]; | |
} |