Comments (4)
That's an interesting idea with the app:gps
but wouldn't that mean that you want to match the value
rather than ignore it?
As far as the form controls go, that API is not guaranteed at the moment. It got us to ElixirConf but we'll be extracting that out into its own library instead of being included in the standard swift ui client. We'll need more time to determine if the API is stable or not.
from liveview-client-swiftui.
Ok so here are some ideas for the event system.
The native app can trigger two different type of events.
- Events that require UX responses (trigger a message, update a table)
- Events that are just important to the server and will not trigger an update to the user ui.
Classes
classDiagram
class IHandleEvents {
- status :: Integer.t
- options :: Map.t
- handle(params :: Map.t)
- init(with: status :: Integer.t, options: options :: Map.t)
- set(options: options :: Map.t)
}
A interface or protocol that defines the behaviour of an event handler.
classDiagram
class PushNotificationEventHandler~IHandleEvents~ { }
An example event handler that will focus on Push Notifications.
This is the Dispatcher of Server Events.
classDiagram
class EventHandlersLocator{
- add(event :: Any~IHandleEvents~)
- get(event :: Any~IHandleEvents~.class.t)
- remove(event :: Any~IHandleEvents~.class.t)
- handlers :: Map.t(key: Any~IHandleEvents~.class.String.t, value: Any~IHandleEvents~)
}
This service will store a single intance of each event handler. These instances are created in AppDelegate.
So a Single Handler can be responsible for dispatching events. The handlers
registry will store
the string representation of the class of each handler as its key.
classDiagram
class ServerEvent {
- name :: String.t
- params :: Map.t
- init(name :: String.t, params :: Map.t)
- send()
- send(params :: Map.t)
}
The object that will send the information to the server and maybe send a message to
the NotificationCenter
UI Events
These events will need to be defined inside the LiveView template, because they will trigger a LiveView handle_event
function.
Example
<app.event name="app:gps:realtime" opts={ [every: :seconds30] }>
In a normal LiveView this maybe a hidden input which will trigger on change event.
<input type="hidden" data-every="seconds30" phx-change="app:gps:realtime" value="">
It will configure the native app event. Enabling it and sending its options as Json.
{
"name": "app:gps:realtime",
"opts": {
"every": "seconds30"
}
}
In the LiveView component
def handle_event("app:gps:realtime", value, socket) do
# server handling code
end
The value would be a json
object containing the data.
If the data is an Image, Sound, File or another not JSON encodable,
it must be encoded as base64
string.
{
"name" : "app:audio",
"data" : "bGlnaHQgdw=="
}
Server Events
These events will send a POST request to a specific endpoint in the server. So they will not be defined in the
template. Since they will not be related to LiveView. The configuration must be done inside the Native App.
from liveview-client-swiftui.
Why can't pushEvent
on the coordinator be used if no user interaction is required?
from liveview-client-swiftui.
It is not planned. Rejecting. We have other way to do that: https://liveview-native.github.io/liveview-client-swiftui/documentation/liveviewnative/liveviewcoordinator/pushevent(type:event:value:target:)
from liveview-client-swiftui.
Related Issues (20)
- remove navigation option, make it always enabled HOT 9
- Modifiers do not match SwiftUI spec. HOT 5
- Can we set the background color for a view, rather than as a modifier on its children? HOT 3
- Unable to set `resizable` modifier on Image HOT 3
- Support livereload when app crashes HOT 10
- LiveViewCoordinator access (pushEvent) HOT 2
- Stabilization: Profile and optimize modifier decoding HOT 1
- Preserve previous document while reconnecting HOT 1
- Change connection format HOT 3
- Proposal on modifiers HOT 74
- Add support for class names to custom registry HOT 2
- Swift Playgrounds Install Failure HOT 2
- [Bug]: Fresh app fails to build due to unsafe build flags HOT 9
- Modifier AST Discussion HOT 1
- Unrecognized views and modifiers shouldn't crash the client HOT 3
- [Bug]: DatePicker `selection` value is not included in `LiveForm` submission unless changed
- Rename `LiveViewNativeSwiftUi` to `LiveViewNative.SwiftUI`
- [Bug]: Error "1st argument: not a binary" when using custom components HOT 5
- [chore]: guides are missing from the hexdocs HOT 1
- [Bug]: No Connection HOT 11
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from liveview-client-swiftui.