Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow building workflows as typed sequences #1942

Merged
merged 5 commits into from
Aug 1, 2024

Conversation

glopesdev
Copy link
Member

@glopesdev glopesdev commented Jul 30, 2024

To support more flexible programmatic manipulation of expression builder workflows, this PR introduces a new overload to compile an expression builder graph into an observable sequence where the type of the elements in the sequence is known.

This makes it possible to load a workflow and perform a type-safe subscription to access the results of the compiled observable sequence, as shown in the example below:

using var reader = XmlReader.Create(path);
var workflowBuilder = (WorkflowBuilder)WorkflowBuilder.Serializer.Deserialize(reader);
var observable = workflowBuilder.Workflow.BuildObservable<object>();

Both covariance and explicit type conversions are allowed in case of type mismatch between the type of the compiled expression and the expected result type.

Fixes #1915

@glopesdev glopesdev added the feature New planned feature label Jul 30, 2024
@glopesdev glopesdev added this to the 2.9 milestone Jul 30, 2024
@glopesdev glopesdev requested a review from PathogenDavid July 30, 2024 11:00
Copy link
Member

@PathogenDavid PathogenDavid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one minor thing, good either way.

This method was used not just for arguments but also several properties
and is an expanded version of Expression.Convert so we renamed it
ConvertExpression and refactored the signature to match the original.
@glopesdev glopesdev merged commit 8f2d560 into bonsai-rx:main Aug 1, 2024
9 checks passed
@glopesdev glopesdev deleted the issue-1915 branch August 1, 2024 10:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New planned feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consider adding BuildObservable overload that returns typed sequence
2 participants