question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

👋🏽 Are you using Morphism for a project or a library ? Please share the way you use it.

See original GitHub issue

Last time, I was thinking about adding more real use cases to the documentation. According to npm, there is a certain amount of downloads, I was wondering how and for what do you use Morphism

Please share you usage or any relevant public link.

example: https://github.com/nobrainr/morphism/issues/33#issuecomment-424129504

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:3
  • Comments:15 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
aslakercommented, May 5, 2020

@emyann below is a snippet that shows how I am using it with useEffect (with some pseudo-ish code). This way the currentBusinessObject is always in a ready-to-post state whenever the user is done making changes. I have an additional file that defines the mapping (a lot of it is one to one, but some of them require a mapping function) The next step that I may take is raise the logic one level higher into my axios instance config, and use Morphism as middleware. Let me know if you have any questions, or suggestions for using Morphism in a better way.

const businessObjectResponse = await fetchComplexBusinessObject();

const [currentUIState, setCurrentUIState] = useState({})
const [currentBusinessObject, setCurrentBusinessObject] = useState({...businessObjectResponse})

useEffect(() => {
    let uiStateCopy = makeDeepClone(currentUIState);
    let updatedBusinessObject = morphism(UIToBusinessObjectSchema, uiStateCopy);
    setCurrentBusinessObject(updatedBusinessObject)
}, [currentUIState])
2reactions
aslakercommented, Apr 30, 2020

Hi @emyann Fantastic library you have here.

I am using it to keep an internal business object that we have defined, in sync with a flattened out UI object that we are using for React application state. This way we can design an internal object that can work with multiple applications (and not care about any specific UI needs), and we can morph that object into a different UI state depending on the needs of the specific application.

Paired with the useEffect hook I am always able to keep a version of our business object in sync with the UI specific state. This makes it really easy to post the updated business object to the server without transforming on the fly.

Thanks again for being generous with your time and building this library. I look forward to using it more.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Code.org Lesson 9.1 Project Make a Library - YouTube
Parameters, Return, and Libraries is unit 7 of Code.org's C.S. Principles course. The course is often used in AP Computer Science classrooms ...
Read more >
Code.org Project Make a Library | Lessons 8, 9, 10 | Unit 7
Project Make a Library is from Parameters, Return, and Libraries is unit 7 of Code.org's C.S. Principles course. The course is often used...
Read more >
The Complicated Role of the Modern Public Library
They are "the original sharing economy," "early warning systems for broad cultural phenomena," offering tai chi lessons, advice, social services, and, yes, ...
Read more >
2019 MLA Annual Conference - Missouri Library Association
We 'll be communicating more details about this, such as time and date as we work ... with ideas and tools they can...
Read more >
Welcome to the 2nd Annual November 16–17, 2016 Dallas, TX
can keep improving to serve you and your libraries. LMC Conference Chair. Amigos Library Services is happy to work with LMCC for our...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found