Everything about Slinky -- issues, ideas for features, where it's being used, and more
shadaj on main
Update sbt-scalafix to 0.10.0 (… (compare)
shadaj on main
Update sbt-sonatype to 3.9.13 (… (compare)
shadaj on main
Have Scala Steward always updat… (compare)
shadaj on main
Update sbt-idea-plugin to 3.13.… (compare)
shadaj on fix-docs-ssr
shadaj on main
Fix docs SSR unnecessarily depe… (compare)
shadaj on fix-docs-ssr
Fix docs SSR unnecessarily depe… (compare)
for example, you can have your normal service that invokes your API, and another implementation depending on such service but handling the cache
@peterstorm this is what I would do, if you use the router, going back doesn't actually refresh the app state, hence, the cache should be live, or you could go hardcore and cache on indexeddb/localstorage, at the end, it is just sharing the same instance on the app's lifecycle
@react
object BasicTable {
case class Props[A](tableData: List[A], tableHead: List[String])
val component = FunctionalComponent[Props[A]] { props =>
Grid(className := "tableResponsive")(
table(className := "tableWrapper")(
thead(className := "tableHead")(
tr(className := "tableRow")(
)
)
)
)
}
}
But doesnt going away from a page unmount the componenet, and thus all the state? So if I have a list of 10 profiles, press a profile to see a detailed view, then the state of the profile search will be unmounted right? So router shouldn't work there, right?
That's why the same cached states should be propagated to all components depending on such data, it should work, where it wouldn't work is when you reload the page, or a new tab is opened
Panel
that can do some operation on two numbers
Panel
s and define linkage between them (dynamically), so that the one panel's output is piped to the other panel's first input.
package connect.ui.components.auth
import slinky.core._
import slinky.core.annotations.react
import slinky.web.html._
import org.scalajs.dom
import slinky.core.facade.{Fragment, ReactElement}
import slinky.web.ReactDOM
import slinky.core.facade.React
import slinky.core.facade.Hooks._
import typings.reactRouterDom.{ components => router}
import scala.scalajs.js
import connect.ui.domain.authentication.Auth
import org.scalablytyped.std.global.console
@react
object AuthContextProvider {
val authContext = React.createContext[Auth](Auth(false, "", "", 0, () => ()))
case class Props(test: String, children: ReactElement*)
val component = FunctionalComponent[Props] { props =>
val (isAuthenticated, setIsAuthenticated) = useState(false)
def loginHandler(): Unit = {
console.log("loginHandler called")
setIsAuthenticated(true)
router.Redirect(to = "/")
}
authContext.Provider(value = Auth(isAuthenticated, "", "", 0, loginHandler _))(
props.children
)
}
}
useContext(AuthContextProvider.authContext)
in a different component
AuthContextProvider.authContext.Consumer( context => ...)
it works