On Wednesday, August 10, 2016 at 1:01:10 PM UTC-6, Janis Voigtländer wrote:
>
> Only one?
>
> Yes, indeed. Note what I wrote there. It talks about filtering
> subscriptions. All the examples you mention do not seem to be about
> subscriptions, but instead about updates that come from other sources,
> probably from HTML events. Where (except keyboard handling) have you wanted
> to apply a filter function to a Sub-typed thing? (Leading us away from
> keyboard, so maybe this is more suitable to continue in the other thread
> about generic subscription filtering.)
>
For actual subscription filters that I am using I have a lot of ports
(integration with javascript code that I am not allowed to get rid of) and
sometimes the port calls are useful and sometimes they are not. My Helpers
library has both a `msg_ignore` and a `cmd_ignore` that I use heavily for
such purposes (which my Helper library swallows thankfully). My
subscriptions used to be fairly large and hairy because of all the checks,
that is since gone and now replaced with:
```elm
subscriptions : Model -> Sub Msgsubscriptions model =
Sub.batch
[ port_MessageOptionCB (\{ text } -> MessageOptionCB text)
, onInfoConnect (\{ msg } -> InfoConnect msg.uid)
, onRoomListInit (\{ msg, cb_data } -> RoomList_Init cb_data
msg.roomlist)
, onRoomListJoined (\{ msg, cb_data } -> RoomList_Joined cb_data
msg.roomlist)
, onRoomListParted (\{ msg, cb_data } -> RoomList_Parted cb_data
msg.roomlist)
, onRoomListNotif (\{ msg, cb_data } -> RoomList_Notif cb_data msg.msgs)
, onRoomClosed (\{ msg, cb_data } -> Room_Part cb_data msg)
, onRoomInfo (\{ msg, cb_data } -> Room_Info cb_data msg)
, onRoomMsgsInit (\{ msg, cb_data } -> RoomMsg_Init cb_data msg)
, onRoomMsgsNew (\{ msg, cb_data } -> RoomMsg_New cb_data msg)
, onRoomUserInit (\{ msg, cb_data } -> RoomUser_Init cb_data msg)
, onRoomUserJoined (\{ msg, cb_data } -> RoomUser_Joined cb_data msg)
, onRoomUserParted (\{ msg, cb_data } -> RoomUser_Parted cb_data msg)
, onRoomNotif (\{ msg, cb_data } -> RoomMsg_Notif cb_data msg.msgs)
, onRoomSyncState (\{ msg, cb_data } -> RoomMsg_SyncState cb_data msg)
, onRoomSyncJoin (\{ msg, cb_data } -> RoomMsg_SyncJoin cb_data msg)
, onRoomSyncLeave (\{ msg, cb_data } -> RoomMsg_SyncLeave cb_data msg)
, {- snip a *lot* more -}
```
Although that call is in a module dedicated to ports and subscriptions so
it is mostly out of sight, but when I had to touch it before it was quite a
mess (and yes I should re-arrange the order of the cb_data, but meh, this
way was more natural in the filter and update calls).
Also, since my last email, more than 100 more lines total are gone. ^.^
--
You received this message because you are subscribed to the Google Groups "Elm
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.