Skip to content

What is the difference between optional and maybe, Instance, SnapshopIn and Out? #2244

Answered by thegedge
OnkelTem asked this question in Q&A
Discussion options

You must be logged in to vote

First, I'll cover the three main types for MST models:

  • SnapshotIn is the input type needed by MyModelType.create to construct an instance
  • Instance is an instance of an MST type. You can usually assign an MST instance into an interface with simple javascript types, but a plain old javascript object (POJO) usually can't be assigned to an MST instance type (as you noticed, and we'll discuss below).
  • SnapshotOut the type of getSnapshot(instance)

Second, here's what the docs say about optional types:

types.optional(type, defaultValue, optionalValues?) marks a value as being optional (in e.g. a model). If a value is not provided/undefined (or set to any of the primitive values passed as an op…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@coolsoftwaretyler
Comment options

Answer selected by coolsoftwaretyler
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants