Comments (8)
Hmm I'm wondering whether it'd make sense to add Operation
class to dry-transaction
. Folks could just do class DoSomething < Dry::Transaction::Operation
. WDYT?
from dry-web-roda.
Sorry to interrupt but what do you mean with Operation
are talking about Transaction operations like step
, tee
, map
etc...
from dry-web-roda.
@GustavoCaso we're talking about typical "functional objects" here, the kind you build hundreds of when you're making a large app (hence the idea of having the basic functionality provided by a shared superclass). For example
class CreateComment < Some::Shared:Operation
def call(attrs)
# ...
end
end
@solnic nice idea to put it in dry-transaction. The reason I didn't initially consider providing this via a gem was that the notion of what an "operation" is might differ from app to app, so by dry-web-roda generating one for you, it was more of a hint that you should consider it for your own app.
That said, if all we'd be looking to do initially is include those 2 mixins, then it does make sense that this could be a Dry::Transaction::Operation
. And that might make adoption of operations/transactions just that little bit easier for people, too.
OK! So if we did that, I still have one question: even if Dry::Transaction::Operation
exists, is there still merit in generating something like this in new dry-web-roda apps?
module MyApp
class Operation < Dry::Transaction::Operation
# shared logic goes here
end
end
I guess if the class if going to be empty, maybe not, but perhaps worth having as a placeholder just in case there's some shared behaviour that an app wants to provide?
from dry-web-roda.
Thanks @timriley for explaining 😄
So if understood correctly Dry::Transaction::Operation
will be such an interface to MyApp::Operation
adding some shared method across all operations?
from dry-web-roda.
@GustavoCaso At this point we're basically just talking about this:
module Dry
module Transaction
class Operation
include Dry::Monads::Either::Mixin
include Dry::Matcher.for(:call, with: Dry::Matcher::EitherMatcher)
end
end
end
from dry-web-roda.
Nice I got it
from dry-web-roda.
OK! So if we did that, I still have one question: even if Dry::Transaction::Operation exists, is there still merit in generating something like this in new dry-web-roda apps?
Yes, I would say it should be a general good practice (just like we do with rom repos), because it gives you a place to inject stuff like loggers, notifiers, integrate with anything that's specific to your app. It also makes it easier to swap implementations for many classes once there's just one abstract class that you own.
from dry-web-roda.
Fixed in #45
from dry-web-roda.
Related Issues (20)
- dry-web-roda requiring generated app dependencies HOT 1
- DRY up the 2 project arch generators HOT 2
- Missing dry-web as a runtime dep in gemspec HOT 1
- dry-monitor SQL Logger - Invalid constructor params HOT 3
- 'view.context' not registered on Container HOT 3
- Require pry-byebug
- Remove deprecated method calls within templates HOT 1
- Version 0.7.5 crashes with dry-system 0.7.3 HOT 1
- Remove rack_csrf dependency HOT 3
- Generator generate misaligned gemfile HOT 7
- dry-web-roda errors out: Cannot load such file -- dry/web/roda/cli (LoadError) HOT 1
- View context config is never used HOT 13
- cannot load such file -- sequel with rackup HOT 7
- Root returns 404 on fresh install HOT 5
- Unable to set a default value for a setting
- Name error on fresh install HOT 2
- Error on start new application: uninitialized constant Dry::Monitor::Rack (NameError) HOT 3
- JRuby tests fail on pg gem not being for Java
- dry-web-roda app initialisation issues HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dry-web-roda.