You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 10, 2019. It is now read-only.
Im aware that this package is getting deprecated but this feature is still alpha in apollo-client.
I need to store function references in client state, is it possible with Apollo?
Example
Native iOS or Android like header component for web (on smaller screen widths). Would be nice to update the header anywhere in app, especially because what icons do on click and what title says usually depends on context/route/state of the world.
Would be so nice to do something like this:
# header component reads this # state and renders accordinglytypeHeader {
title: Stringsubtitle: Stringleft: HeaderButtonright: HeaderButton
}
typeHeaderButton {
icon: Stringcallback: Function
}
extendtypeQuery {
header: Header
}
// React componentfunctionAnywhereInApp(props){// writeData is here for demo purpouse, would// be a waste to (try) write on each re-renderclient.writeData({data: {header: {__typename: 'Header',title: 'New Title',subtitle: '',left: {icon: 'back-arrow',callback: ()=>{window.history.back();}},right: {icon: 'settings',callback: ()=>{openSettingsModal();}}}}});functionopenSettingsModal(){// do something}return(/* ... */);}
Im currently managing local state with React context which can have any value (including references), I'd be very happy if I could 100% replace context client state management with Apollo.
I have one hack in mind and it's a spicy one:
Set callback to window object, e.g to window.myAppName[name]
Write callback name (string) instead of reference to store
Read callback name from cache among other values
Use callback like this window.myAppName[name]()
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Im aware that this package is getting deprecated but this feature is still alpha in
apollo-client
.I need to store function references in client state, is it possible with Apollo?
Example
Native iOS or Android like header component for web (on smaller screen widths). Would be nice to update the header anywhere in app, especially because what icons do on click and what title says usually depends on context/route/state of the world.
Would be so nice to do something like this:
Im currently managing local state with React context which can have any value (including references), I'd be very happy if I could 100% replace context client state management with Apollo.
I have one hack in mind and it's a spicy one:
window.myAppName[name]
name
(string) instead of reference to storename
from cache among other valueswindow.myAppName[name]()
The text was updated successfully, but these errors were encountered: