In the elm git book an architecture is described wherein child components generate messages which are disseminated via the main update function, eventually being handled by the appropriate update function in a child component. How does the translator pattern differ from this and what are the use cases of each pattern. Please provide a simple example.
What is the translator pattern in elm?
339 Views Asked by sjt003 At
1
There are 1 best solutions below
Related Questions in DESIGN-PATTERNS
- Pass Data between two view controllers using 'Delegation' : Objective-C
- Revealing module pattern instantiation and naming convention
- Is using the same Redis instance for different applications against Separation of Concerns principle?
- Swift - Issue trying to access to Singleton object
- How to set data context of ViewModela View's xaml?
- How to use nested builder pattern in json?
- Is object casting a good practice?
- reference data class member visitor pattern
- variable global const "macros" in C++ and optimal design patterns
- How to design abstract listener and its implementation?
- DTOs with different granularity
- Object creation depending on caller
- What is the proper way to use inheritance when combined with factory method?
- Is this Java Enumeration Used/Designed Correctly?
- Design pattern for incremental code
Related Questions in FUNCTIONAL-PROGRAMMING
- Access into a Binary Search Tree via a bound function in a function template
- Convert loop to Maybe monad
- Lazy concat in Immutable.js?
- Erlang syntax error unclear
- What is the type of the variable in do-notation here in Haskell?
- Lazy functions evaluation in swift
- Standard ML / NJ: Loading in file of functions
- First Object in Set<Future<Object>> that satisfies a predicate
- How to write a type that is isomorphic to Tree without nested lists?
- Functional way of doing a loop of operations on an array
- Good practice on how to store the result of a function for later use in R
- Apply a list of Functions to a Java stream's .map() method
- First word of binary string erlang
- Easier way to apply multiple arguments in Haskell
- scala : use of braces for a function when the parameter is a predicate
Related Questions in REACTIVE-PROGRAMMING
- How to prevent Scan from running multiple times?
- Throwing data through narrow gate with Rx (Reactive Extensions)
- How cancel task with retrofit and rxjava
- Combine params from two Observables to execute the third one
- How to ensure that all observers see the same result from multiple parallel subscription
- Pub/Sub Vs Observer Vs Reactive
- RxJava- performing a peek() or void operation within an Observable chain?
- Modulating audio signal with Euterpea
- RxJS error handling
- How cancel network request in retrofit and rxjava
- Shiny R reactivevalues memory leak
- RxJava- Placing several Observable values in a static body of text?
- JavaFX and RxJava- TableView infinitely calling setCellValueFactory()
- Create Observable from side-effects in Do block
- ReactiveCocoa Combine Latest with Button press and Text Field Delegate Signal
Related Questions in MESSAGE
- Scrollbar for Message Widget in Tkinter
- How to process A direct send message to a thread of process B?
- Cluster PHP messages array
- erlang processes and message passing architecture
- FluentValidation - How to customize the validation message in runtime
- Storing all conversations in a table
- How to write CHARACTER variable to file in ESQL?
- Laravel5 illuminate composer messagebag package
- Random quote page reload javascript
- Chrome-extension undefined response from background to popup
- Primefaces duplicate messages in dialog and page
- Sending messages with AppleScript
- How would I send an alert or message to a view from a Django model's (overridden) save( ) function?
- CakePHP 2.x Sending user messages to element('menu')
- Facebook automatic Birthday wish
Related Questions in ELM
- In Elm, why is this an Int-Float type mismatch?
- How do I make two independent actions inside one function?
- Is there a way to cache a function result in elm?
- How align three forms vertically in Elm?
- Check for differences of two sets in Elm
- What is elm-make: Map.!: given key is not an element in the map
- Typescript: default export and namespace dual behavior as in Elm
- Elm 0.18 Http requests
- Elm-live opens wrong js file
- Elm error: I am looking for one of the following things: "'"
- Objects into JSON decoder through Elm ports
- Elm Lists of types & type aliases -- getting the extracted Lists to recognize the type
- Module `Html` does not expose `beginnerProgram`
- What is the translator pattern in elm?
- Elm 0.18 material design
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Whenever you have a nested "component" with an
updatefunction, you will need to make sure the parent passes through the child Msgs and Cmds. The git book outlines this with a simple example (where this code is in the parent, andWidgetis the child):The above will be necessary any time a child has an
updatefunction. However, the in the above example, the parent never knows or cares what child messages are being communicated to the child.But now, consider the case that a parent needs to know about a Msg generated by a child. For instance: a game where a nested child component needs to communicate with a parent that the game is lost.
The Translator Pattern is useful when a parent component needs to react to a message returned from the child update function. Here is the basic structure of the update function in the linked example:
Notice that it looks a lot like the earlier
updateexample; the main difference is that rather than mapping theCmddirectly to a blind parentMsg(blind in that the singleWidgetMsgof the first example only passed around the childMsg), thegameTranslatormapping function allows you to map to one of the parent messages.It may be helpful to read the Translator Pattern Blog Post in its entirety. It was written for Elm 0.17 so there are a few syntax changes, but the general idea still holds.